home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / pgmr_faq.zip / DOS_PGMR.FAQ next >
Internet Message Format  |  1993-01-05  |  104KB

  1. Path: nlbbs!gator!news.dell.com!swrinde!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!ncoast!brown
  2. From: brown@NCoast.ORG (Stan Brown)
  3. Newsgroups: comp.os.msdos.programmer,news.answers
  4. Subject: comp.os.msdos.programmer FAQ part 1 of 4
  5. Message-ID: <msdos-faq.921220.1@NCoast.ORG>
  6. Date: Sun, 20 Dec 1992 20:12:47 GMT
  7. Expires: Wed, 3 Feb 1993 20:12:47 GMT
  8. References: none
  9. Followup-To: comp.os.msdos.programmer
  10. Organization: Oak Road Systems, Cleveland Ohio USA
  11. Lines: 190
  12. Approved: news-answers-request@MIT.Edu
  13. Supersedes: <msdos-faq.921205.1@NCoast.ORG>
  14.  
  15. Archive-name: msdos-programmer-faq/part1
  16. Last-modified: 20 December 1922
  17.  
  18.  
  19. This is the monthly FAQ list (Frequently Asked Questions list) for the
  20. newsgroup comp.os.msdos.programmer.  Parts 2 through 4 of this article
  21. are posted as followups in the same thread.  If the posting date shown
  22. above is more than six weeks in the past, see instructions in part 4 of
  23. this list for how to get an updated copy.  (A separate article holds the
  24. changes from last month's edition.  Look for the subject line
  25. "comp.os.msdos.programmer FAQ diffs".)
  26.  
  27. FAQ lists are intended to reduce the noise level in their newsgroups
  28. that results from the repetition of the same questions, correct answers,
  29. wrong answers, corrections to the wrong answers, corrections to the
  30. corrections, debate, etc.
  31.  
  32. This list should serve as a repository of the canonical "best" answers
  33. to the questions in it.  The names of folks who have helped to improve
  34. this FAQ list follow the table of contents.  If you know a better answer
  35. or even a slight change that improves an answer, please tell me!  (Use
  36. email, please.  Traffic in this group is high, and I may miss a relevant
  37. posted article.)
  38.                       Stan Brown, Oak Road Systems, Cleveland, Ohio, USA
  39.                                                         brown@ncoast.org
  40.  
  41. Search tips
  42. ===========
  43.     To search for specific topics:  See the list of questions in the
  44. Contents section (immediately below) to find which article (part 2, 3,
  45. or 4) you need.  Then, in that part, search for that question number.
  46. For example, while you're reading part 2 of this list, the trn
  47. newsreader command "gQ203" goes to Q203.
  48.     To skip one topic and go to the next:  Search for "Q" starting in
  49. column 1.  In trn and similar newsreaders, the command "g^Q" does that.
  50.     If your newsreader doesn't support searches, you can extract these
  51. articles to a file and use your favorite editor's search commands.
  52.  
  53.  
  54. Contents--part 2 of 4
  55. =====================
  56. section 1. General questions
  57.     101. Why won't my code work?
  58.     102. What is this newsgroup about?
  59.     103. What's the difference from comp.sys.ibm.pc.programmer?
  60.     104. What other newsgroups should I know about?
  61. section 2. Compile and link
  62.     201. What the heck is "DGROUP > 64K"?
  63.     202. How do I fix "automatic data segment exceeds 64K" or "stack
  64.          plus data exceed 64K"?
  65.     203. Will Borland C code and Microsoft C code link together?
  66.     204. Why did my program bomb at run time with "floating point
  67.          formats not linked"?
  68.     205. Why did my program bomb with "floating point not loaded"?
  69.     206. How can I change the stack size in Borland's C compilers?
  70.     207. What's the format of an .OBJ file?
  71.     208. What's the format of an .EXE header?
  72.     209. What's the difference between .COM and .EXE formats?
  73. section 3. Keyboard
  74.     301. How can I read a character without echoing it to the screen,
  75.          and without waiting for the user to press the Enter key?
  76.     302. How can I find out whether a character has been typed, without
  77.          waiting for one?
  78.     303. How can I disable Ctrl-C/Ctrl-Break and/or Ctrl-Alt-Del?
  79.     304. How can I disable the print screen function?
  80.     305. How can my program turn NumLock (CapsLock, ScrollLock) on/off?
  81.     306. How can I speed up the keyboard's auto-repeat?
  82.     307. What is the SysRq key for?
  83.     308. How can my program tell what kind of keyboard is on the system?
  84.     309. How can I tell if input, output, or stderr has been redirected?
  85.  
  86.  
  87. Contents--part 3 of 4
  88. =====================
  89. section 4. Disks and files
  90.     401. What drive was the PC booted from?
  91.     402. How can I boot from drive b:?
  92.     403. Which real and virtual disk drives are valid?
  93.     404. How can I make my single floppy drive both a: and b:?
  94.     405. Why won't my C program open a file with a path?
  95.     406. How can I redirect printer output to a file?
  96.     407. How can my program open more files than DOS's limit of 20?
  97.     408. How can I read, create, change, or delete the volume label?
  98.     409. How can I get the disk serial number?
  99.     410. What's the format of .OBJ, .EXE., .COM files?
  100. section 5. Serial ports (COM ports)
  101.     501. How do I set my machine up to use COM3 and COM4?
  102.     502. How do I find the I/O address of a COM port?
  103.     503. But aren't the COM ports always at I/O addresses 3F8, 2F8, 3E8,
  104.          and 2E8?
  105.     504. How do I configure a COM port and use it to transmit data?
  106. section 6. Other hardware questions and problems
  107.     601. Which 80x86 CPU is running my program?
  108.     602. How can a C program send control codes to my printer?
  109.     603. How can I redirect printer output to a file?
  110.     604. Which video adapter is installed?
  111.     605. How do I switch to 43- or 50-line mode?
  112.     606. How can I find the Microsoft mouse position and button status?
  113.     607. How can I access a specific address in the PC's memory?
  114.     608. How can I read or write my PC's CMOS memory?
  115.     609. How can I access memory beyond 640K?
  116. section 7. Other software questions and problems
  117.     701. How can a program reboot my PC?
  118.     702. How can I time events with finer resolution than the system
  119.          clock's 55 ms (about 18 ticks a second)?
  120.     703. How can I find the error level of the previous program?
  121.     704. How can a program set DOS environment variables?
  122.     705. How can I change the switch character to - from /?
  123.     706. Why does my interrupt function behave strangely?
  124.     707. How can I write a TSR (terminate-stay-resident) utility?
  125.     708. How can I write a device driver?
  126.     709. What can I use to manage versions of software?
  127.     710. What's this "null pointer assignment" after my C program
  128.          executes?
  129.  
  130.  
  131. Contents--part 4 of 4
  132. =====================
  133. section A. Downloading
  134.     A01. What is garbo?  What is wustl?
  135.     A02. What are Simtel and "mirror sites"?  What good are they?
  136.     A03. Where do I find program <mumble>?
  137.     A04. How can I check Simtel or garbo before I post a request for a
  138.          program?
  139.     A05. How do I download and decode a program I found?
  140.     A06. Where is UUDECODE?
  141.     A07. Why do I get errors when extracting from a ZIP file I
  142.          downloaded?
  143. section B. Vendors and products
  144.     B01. How can I contact Borland?
  145.     B02. How can I contact Microsoft?
  146.     B03. What's the current version of PKZIP?
  147.     B04. What's in Borland Pascal/Turbo Pascal 7.0?
  148.     B05. What's in Microsoft C/C++ 7.0?
  149. section C. More information
  150.     C01. Are there any good on-line references for PC hardware
  151.          components?
  152.     C02. Are there any good on-line references for PC interrupts?
  153.     C03. What and where is "Ralf Brown's interrupt list"?
  154.     C04. Where can I find lex, yacc, and language grammars?
  155.     C05. What's the best book to learn programming?
  156.     C06. Where are FAQ lists archived?
  157.     C07. Where can I get the latest copy of this FAQ list?
  158.  
  159.  
  160. Acknowledgements
  161. ================
  162. Many articles posted in comp.os.msdos.programmer sparked ideas or
  163. provided information for the first version of this list.  Though I am
  164. responsible for any errors, thanks are due to the following for posted
  165. articles or private email that I used in subsequent editions:  Jamshid
  166. Afshar, Mark Aitchison, Sanjay Aiyagari, George Almasi, Aaron Auseth,
  167. Preston Bannister, Denis Beauregard, Mike Black, Glynn Brooks, Paul
  168. Brooks, Ralf Brown, Shaun Burnett, Raymond Chen, Alan Drew, Paul
  169. Ducklin, Gary Dueck, Roland Eriksson, Markus Fischer, George Forsman,
  170. B.Haible, Klaus Hartnegg, Kris Heidenstrom, Joel Hoffman, Joe Huffman,
  171. Michael Holin, Mike Iarrobino, Ajay Kamdar, Everett Kaser, Jen Kilmer,
  172. Reinhard Kirchner, Dave Kirsch, Sidney Markowitz, Jim Marks, Dimitri
  173. Matzarakis, Ken McKee, Tom Milner, Duncan Murdoch, Steve Murphy, Mert
  174. Nickerson, David Nugent, Keith Petersen, Karl Riedling, Arthur Rubin,
  175. Gerald Ruderman, Timo Salmi, Tapio Sand, John Schmid, Ajay Shah, Tom
  176. Swingle, Anders Thulin, Curt Tilmes, Ya-Gui Wei, Joe Wells, Gregory
  177. Youngblood, khill@vax1.umkc.edu, rujo@extern.uio.no
  178.  
  179. New contributors this month:  Paul Ducklin, Mike Iarrobino, Duncan
  180. Murdoch, Anders Thulin, Curt Tilmes, rujo@extern.uio.no
  181.  
  182.  
  183. Legalistic stuff
  184. ================
  185. This article is not in the public domain, but it may be redistributed so
  186. long as this notice, and the information on obtaining the latest copy of
  187. this list, are retained.  The code fragments may be used freely; credit
  188. would be appreciated but is not required.
  189.  
  190. Copyright (C) 1992  Stan Brown, Oak Road Systems.  All rights reserved.
  191.  
  192. THERE IS NO WARRANTY ON THE CODE.  I have tested all the code included
  193. below, but your machine may not work the same as mine, and my testing
  194. may not be perfect.  (Except where otherwise noted, I tested the code
  195. with both BC++ 2.0 and MSC 5.0.)
  196.  
  197. The mention of particular books or programs must not be construed to
  198. reflect unfavorably on any that are not mentioned.
  199.  
  200.  
  201. (continued in part 2)
  202. -- 
  203. Stan Brown, Oak Road Systems                      brown@Ncoast.ORG
  204. Cleveland, Ohio, USA
  205. Path: nlbbs!gator!news.dell.com!swrinde!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!ncoast!brown
  206. From: brown@NCoast.ORG (Stan Brown)
  207. Newsgroups: comp.os.msdos.programmer,news.answers
  208. Subject: comp.os.msdos.programmer FAQ part 2 of 4
  209. Message-ID: <msdos-faq.921220.2@NCoast.ORG>
  210. Date: Sun, 20 Dec 1992 20:13:14 GMT
  211. Expires: Wed, 3 Feb 1993 20:13:14 GMT
  212. References: <msdos-faq.921220.1@NCoast.ORG>
  213. Followup-To: comp.os.msdos.programmer
  214. Organization: Oak Road Systems, Cleveland Ohio USA
  215. Lines: 589
  216. Approved: news-answers-request@MIT.Edu
  217. Supersedes: <msdos-faq.921205.2@NCoast.ORG>
  218.  
  219. Archive-name: msdos-programmer-faq/part2
  220. Last-modified: 20 December 1922
  221.  
  222. (continued from part 1)         (no warranty on the code or information)
  223.  
  224. If the posting date is more than six weeks in the past, see instructions
  225. at the end of this article for how to get an updated copy.
  226.  
  227.             Copyright (C) 1992  Stan Brown, Oak Road Systems
  228.  
  229.  
  230. section 1. General questions
  231. ============================
  232.  
  233. Q101. Why won't my code work?
  234.  
  235.     First you need to try to determine whether the problem is in your
  236.     use of the programming language or in your use of MSDOS and your PC
  237.     hardware.  (Your manual should tell you which features are standard
  238.     and which are vendor- or MSDOS- or PC-specific.  You _have_ read
  239.     your manual carefully, haven't you?)
  240.  
  241.     If the feature that seems to be working wrong is something related
  242.     to your PC hardware or to the internals of MS-DOS, this group is the
  243.     right place to ask.  (Please check this list first, to make sure
  244.     your question isn't already answered.)
  245.  
  246.     On the other hand, if your problem is with the programming language,
  247.     the comp.lang hierarchy (including comp.lang.pascal and comp.lang c)
  248.     is probably a better resource.  Please read the other group's FAQ
  249.     list thoroughly before posting.  (These exist in comp.lang.c,
  250.     comp.lang.c++, comp.lang.modula3, comp.lang.lisp, comp.lang.perl;
  251.     they may exist in other groups as well.)  It's almost never a good
  252.     idea to crosspost between this group and a language group.
  253.  
  254.     Before posting in either place, try to make your program as small as
  255.     possible while still exhibiting the bad behavior.  Sometimes this
  256.     alone is enough to show you where the trouble is.  Also edit your
  257.     description of the problem to be as short as possible.  This makes
  258.     it look more like you tried to solve the problem on your own, and
  259.     makes people more inclined to try to help you.
  260.  
  261.     When you do post a question, it's good manners to say "email please;
  262.     I'll post a summary."  Then everybody else in the group doesn't have
  263.     to read ten virtually identical responses.  Of course, then you have
  264.     to follow through.  A summary is not simply pasting together all the
  265.     email you received.  Instead, write your own (brief) description of
  266.     the solution:  this is the best way to make sure you really
  267.     understand it.  Definitely don't repost people's cute signatures.
  268.  
  269. Q102. What is this newsgroup about?
  270.  
  271.     comp.os.msdos.programmer (comp.sys.ibm.pc.programmer until September
  272.     1990) concerns programming for MS-DOS systems.  The article "USENET
  273.     Readership report for Nov 92" in news.lists shows 42,000 readers of
  274.     this newsgroup worldwide.  Traffic was 1090.7 Kbytes (exclusive of
  275.     crossposts), comprised in 611 articles.
  276.  
  277.     Much of our traffic is about language products (chiefly from Borland
  278.     and Microsoft).  More programming topics focus on C than on any one
  279.     other language.
  280.  
  281.     Since most MS-DOS systems run on hardware that is roughly compatible
  282.     with the IBM PC, on Intel 8088, 80188, or 80x86 chips, we tend to
  283.     get a lot of questions and answers about programming other parts of
  284.     the hardware.
  285.  
  286. Q103. What's the difference from comp.sys.ibm.pc.programmer?
  287.  
  288.     c.s.i.p.programmer is the old name of comp.os.msdos.programmer, and
  289.     has been obsolete since September 1990.  However, many systems have
  290.     not removed the old group, or have removed it but aliased it to the
  291.     new name.  This means that some people still think they're posting
  292.     to c.s.i.p.programmer even though they're actually posting to
  293.     c.o.m.programmer.
  294.  
  295.     You can easily verify the non-existence of c.s.i.p.programmer by
  296.     reference to the "List of Active Newsgroups" posted to news.groups.
  297.     It's available as /pub/usenet/news.answers/active-newsgroups/part1
  298.     from the archives (see "Where are FAQ lists archived?" in section C,
  299.     "More information").
  300.  
  301. Q104. What other newsgroups should I know about?
  302.  
  303.     Your best bet is to read the periodic information postings in the
  304.     comp.binaries.ibm.pc newsgroup.  Specially helpful articles:
  305.         Using the comp.binaries.ibm.pc.d groups
  306.         Beginner's guide to binaries
  307.         Starter kit
  308.         About archives and archivers
  309.     Please wait for these articles to come around; don't post a request.
  310.  
  311.     Also check out news.announce.newusers, even if you're not a new
  312.     user.  You may be surprised how much useful information is in the
  313.     monthly postings there.  Lots of old-timers also get useful stuff
  314.     from news.newusers.questions, especially the periodic postings.
  315.  
  316.     Remember that it's good manners to subscribe to any newsgroup and
  317.     read it for a while before you post a question.  When you post, it's
  318.     also good manners to ask for replies to be emailed and then to post
  319.     a summary, which you've edited down to the absolute minimum size.
  320.  
  321.     You may also be interested in the following newsgroups.  Caution:
  322.     Some of them have specialized charters; you'll probably get (and
  323.     deserve) some flames if you post to an inappropriate group.
  324.  
  325.     - misc.forsale.computers and misc.forsale.computers.pc-clone are
  326.       where you post notices of equipment, software, or computer books
  327.       that you want to sell.  Please don't post or crosspost those
  328.       notices to comp.os.msdos.programmer.
  329.  
  330.     - comp.os.ms-windows.programmer.tools and ...misc (formerly part of
  331.       comp.windows.ms.programmer):  Similar to this group, but focus
  332.       on programming for the MS-Windows platform.
  333.  
  334.     - comp.sys.ibm.pc.hardware is for more hardware-oriented discussions
  335.       of the machines that run DOS.
  336.  
  337.     - comp.binaries.ibm.pc.wanted: AFTER you have looked in the other
  338.       groups, this is the place to post a request for a particular
  339.       binary program.
  340.  
  341.     - comp.binaries.msdos.announce (moderated) explains how to use the
  342.       archive sites, especially garbo and Simtel, and lists files
  343.       uploaded to them.  Discussions belong in comp.binaries.msdos.d,
  344.       which replaced comp.binaries.ibm.pc.archives.
  345.  
  346.     - comp.binaries.ibm.pc.d is for discussions about programs posted in
  347.       comp.binaries.ibm.pc, and only those programs.  This is a good
  348.       place to report bugs in the programs, but not to ask where to find
  349.       them (see cbip.wanted, above).  cbip.d is NOT supposed to be a
  350.       general PC discussion group.
  351.  
  352.     - comp.sources.misc: a moderated group for source code for many
  353.       computer systems.  It tends to get lots of Unix stuff, but you may
  354.       also pick up some DOS-compatible code here.
  355.  
  356.     - alt.sources: an unmoderated group for source code.  Guidelines are
  357.       posted periodically.
  358.  
  359.     - Turbo Vision is a mailing list, not a newsgroup; send email to
  360.       listserv@vtvm1.cc.vt.edu if you want to subscribe.
  361.  
  362.  
  363. section 2. Compile and link
  364. ===========================
  365.  
  366. Q201. What the heck is "DGROUP > 64K"?
  367.  
  368.     DGROUP is a link-time group of data segments, and the compiler
  369.     typically generates code that expects DS to be pointing to DGROUP.
  370.     (Exception: Borland's huge model has no DGROUP.)
  371.  
  372.     Here's what goes into DGROUP:
  373.  
  374.     - tiny model (all pointers near):  DGROUP holds the entire program.
  375.  
  376.     - small and medium models (data pointers near):  DGROUP holds all
  377.       globals and static variables including string literals, plus the
  378.       stack and the heap.
  379.  
  380.     - large, compact, and huge models in Microsoft (data pointers far):
  381.       DGROUP holds only initialized globals and static variables
  382.       including string literals, plus the stack and the near heap.
  383.  
  384.     - large and compact models in Borland (data pointers far): DGROUP
  385.       holds initialized and uninitialized globals and static variables
  386.       including string literals, but not the stack or heap.
  387.  
  388.     - huge model in Borland (data pointers far): there is no DGROUP, so
  389.       the 64K limit doesn't apply.
  390.  
  391.     In all of the above, which is to say all six models in Microsoft C
  392.     and all but huge in Borland C, DGROUP is limited to 64K including
  393.     string literals (which are treated as static data).  This limitation
  394.     is due to the Intel CPU's segmented architecture.
  395.  
  396.     See the next Q for possible remedies.
  397.  
  398.     For more information, see topics like "memory models" and "memory
  399.     management" in the index of your compiler manual.  Also see
  400.     TI738.ASC in PD1:<MSDOS.TURBO-C>BCHELP10.ZIP at Simtel for an
  401.     extended general discussion of memory usage in Borland C programs,
  402.     of which much applies to any C compiler in DOS.
  403.  
  404. Q202. How do I fix "automatic data segment exceeds 64K" or "stack plus
  405.       data exceed 64K"?
  406.  
  407.     These messages are a variation of "DGROUP > 64K".  For causes,
  408.     please see the preceding Q.
  409.  
  410.     If you get this error in tiny model, your program is simply too big
  411.     and you must use a different memory model.  If you get this link
  412.     error in models S, C, M, L, or Microsoft's H, there are some things
  413.     you can do.  (This error can't occur in Borland's huge model.)
  414.  
  415.     If you have one or two big global arrays, simply declare them far.
  416.     The compiler takes this to mean that any references to them will use
  417.     32-bit pointers, so they'll be in separate segments and no longer
  418.     part of DGROUP.
  419.  
  420.     Or you can use the /Gt[number] option with Microsoft or -Ff[=size]
  421.     with Borland C++ 2.0 and up.  This will automatically put variables
  422.     above a certain size into their own segments outside of DGROUP.
  423.  
  424.     Yet another option is to change global arrays to far pointers.  Then
  425.     at the beginning of your program, allocate them from the far heap
  426.     (_fmalloc in Microsoft, farmalloc in Borland).
  427.  
  428.     Finally, you can change to huge model (with Borland compilers, not
  429.     Microsoft).  Borland's H model still uses far pointers by default,
  430.     but "sets aside the [64K] limit" and has no DGROUP group, according
  431.     to the BC++ 2.0 Programmer's Guide.  Microsoft's H model does use
  432.     huge data pointers by default but retains DGROUP and its 64K limit,
  433.     so switching to the H model doesn't buy you anything if you have
  434.     DGROUP problems.
  435.  
  436. Q203. Will Borland C code and Microsoft C code link together?
  437.  
  438.     Typically this question is asked by someone who owns compiler A and
  439.     is trying to write code to link with a third-party library that was
  440.     compiled under compiler B.
  441.  
  442.     The answer to the question is, Not in general.  Here are some of the
  443.     reasons:
  444.  
  445.     - "Helper" functions (undocumented functions for stack checking,
  446.       floating-point arithmetic, and operations on longs) differ between
  447.       the two compilers.
  448.  
  449.     - The compilers may embed instructions in the object code that tell
  450.       the linker to look for their own run-time libraries.
  451.  
  452.     Those problems will generate link-time errors.  Others may not show
  453.     up until run time:
  454.  
  455.     - Borland's compact, large, and huge models don't assume DS=SS, but
  456.       Microsoft's do.  The -Fs option on the Borland compiler, or one of
  457.       the /A options on Microsoft, should take care of this problem --
  458.       once you know that's what's going on.
  459.  
  460.     - Check conventions for ordering and packing structure members, and
  461.       for alignment of various types on byte, word, paragraph, or other
  462.       boundaries.  Again, you can generally adjust your code to match if
  463.       you know what conventions were used in compiling the "foreign"
  464.       libraries.
  465.  
  466.     - Check the obvious and make sure that your code was compiled under
  467.       the same memory model as the code you're trying to link with.
  468.       (That's necessary, but no guarantee.  Microsoft and Borland don't
  469.       use exactly the same conventions for segments and groups,
  470.       particularly in the larger memory models.)
  471.  
  472.     That said, there are some circumstances where you can link hybrids.
  473.     Your best chance of success comes if you avoid longs and floating
  474.     point, use only 16-bit pointers, suppress stack checking, and
  475.     specify all libraries used in the link.
  476.  
  477. Q204. Why did my program bomb at run time with "floating point formats
  478.       not linked"?
  479.  
  480.     First, is that the actual message, or did it say "floating point not
  481.     loaded"?  If it was the latter, see the next Q.
  482.  
  483.     You're probably using a Borland compiler for C or C++ (including
  484.     Turbo C and Turbo C++).  Borland's compilers try to be smart and not
  485.     link in the floating-point (f-p) library unless you need it.  Alas,
  486.     they all get the decision wrong.  One common case is where you don't
  487.     call any f-p functions, but you have %f or other f-p formats in
  488.     scanf/printf calls.  The cure is to call an f-p function, or at
  489.     least force one to be present in the link.
  490.  
  491.     To do that, define this function somewhere in a source file but
  492.     don't call it:
  493.  
  494.         static void forcefloat(float *p)
  495.             { float f = *p; forcefloat(&f); }
  496.  
  497.     It doesn't have to be in the module with the main program, as long
  498.     as it's in a module that will be included in the link.
  499.  
  500.     A new solution for Borland C++ 3.0 was posted, but I don't own the
  501.     product and have not been able to verify it.  Insert these
  502.     statements in your program:
  503.  
  504.         extern unsigned _floatconvert;
  505.         #pragma extref _floatconvert
  506.  
  507. Q205. Why did my program bomb with "floating point not loaded"?
  508.  
  509.     That is Microsoft C's run-time message when the code requires a
  510.     numeric coprocessor but your computer doesn't have one installed.
  511.  
  512.     If the program is yours, relink it using the xLIBCE or xLIBCA
  513.     library (where x is the memory model).
  514.  
  515. Q206. How can I change the stack size in Borland's C compilers?
  516.  
  517.     In Turbo C, Turbo C++, and Borland C++, you may not find "stack
  518.     size" in the index but the global variable _stklen should be there.
  519.     The manual will instruct you to put a statement like
  520.  
  521.         extern unsigned _stklen = 54321U;
  522.  
  523.     in your code, outside of any function.  You must assign the value
  524.     right in the extern statement; it won't work to assign a value at
  525.     run time.  (The "extern" in this context isn't ANSI C and ought not
  526.     to be required, but the above statement is a direct quote from the
  527.     Library Reference manual of Borland C++ 2.0.)  The linker may give
  528.     you a duplicate symbol warning, which you can ignore.
  529.  
  530. Q207. What's the format of an .OBJ file?
  531.  
  532.     Here's what I've been told, though I have verified any of these
  533.     references myself:
  534.  
  535.     - base .OBJ format:  Intel's document number #121748-001, {8086
  536.       Relocatable Object Module Formats}.  (Note however that both
  537.       Microsoft and Borland formats have extended the .OBJ format.)
  538.  
  539.     - Microsoft-specific .OBJ formats:  a "Microsoft OMF Specification"
  540.       (document number ??), as well as a section in the MS-DOS
  541.       encyclopedia.
  542.  
  543.     - A "tutorial on the .OBJ format" comes with the VAL experimental
  544.       linker, which is VAL-LINK.ARC in PD1:<MSDOS.PGMUTL> at Simtel.
  545.  
  546.     If you have specific references, either to fpt-able documents or to
  547.     published works (author, title, order number or ISBN), please email
  548.     them to brown@ncoast.org for inclusion in the next edition of this
  549.     list.
  550.  
  551. Q208. What's the format of an .EXE header?
  552.  
  553.     See pages 349-350 of {PC Magazine}'s June 30, 1992 issue (xi:12) for
  554.     the old and new formats.  For a more detailed layout, look under INT
  555.     21 function 4B in Ralf Brown's interrupt list.  Ralf Brown's list
  556.     includes extensions for Borland's TLINK and Borland debugger info.
  557.  
  558.     Among the books that detail formats of executable files are {DOS
  559.     Programmer's Reference: 2d Edition} by Terry Dettman and Jim Kyle,
  560.     ISBN 0-88022-458-4; and {Microsoft MS-DOS Programmer's Reference},
  561.     ISBN 1-55615-329-5.
  562.  
  563. Q209. What's the difference between .COM and .EXE formats?
  564.  
  565.     To oversimplify:  a .COM file is a direct image of core, and an .EXE
  566.     file will undergo some further relocation when it is run (and so it
  567.     begins with a relocation header).  A .COM file is limited to 64K for
  568.     all segments combined, but an .EXE file can have as many segments as
  569.     your linker will handle and be as large as RAM can take.
  570.  
  571.     The actual file extension doesn't matter.  DOS knows that a file
  572.     being loaded is in .EXE format if its first two bytes are MZ or ZM;
  573.     otherwise it is assumed to be in .COM format.  For instance, I am
  574.     told that DR-DOS 6.0's COMMAND.COM is in .EXE format.
  575.  
  576.  
  577. section 3. Keyboard
  578. ===================
  579.  
  580. Q301. How can I read a character without echoing it to the screen, and
  581.       without waiting for the user to press the Enter key?
  582.  
  583.     The C compilers from Microsoft and Borland offer getch (or getche to
  584.     echo the character); Turbo Pascal has ReadKey.
  585.  
  586.     In other programming languages, load 8 in register AH and execute
  587.     INT 21; AL is returned with the character from standard input
  588.     (possibly redirected).  If you don't want to allow redirection, or
  589.     you want to capture Ctrl-C and other special keys, use INT 16 with
  590.     AH=10; this will return the scan code in AH and ASCII code (if
  591.     possible) in AL, except that AL=E0 with AH nonzero indicates one of
  592.     the grey "extended" keys was pressed.  (If your BIOS doesn't
  593.     support the extended keyboard, use INT 16 function 0 not 10.)
  594.  
  595. Q302. How can I find out whether a character has been typed, without
  596.       waiting for one?
  597.  
  598.     In Turbo Pascal, use KeyPressed.  Both Microsoft C and Turbo C offer
  599.     the kbhit( ) function.  All of these tell you whether a key has been
  600.     pressed.  If no key has been pressed, they return that information
  601.     to your program.  If a keystroke is waiting, they tell your program
  602.     that but leave the key in the input buffer.
  603.  
  604.     You can use the BIOS call, INT 16 function 01 or 11, to check
  605.     whether an actual keystroke is waiting; or the DOS call, INT 21
  606.     function 0B, to check for a keystroke from stdin (subject to
  607.     redirection).  See Ralf Brown's interrupt list.
  608.  
  609. Q303. How can I disable Ctrl-C/Ctrl-Break and/or Ctrl-Alt-Del?
  610.  
  611.     You can download the file PD1:<MSDOS.KEYBOARD>CADEL.ZIP from Simtel.
  612.     It contains a TSR to disable those keys, with source code in ASM.
  613.  
  614.     To disable only Ctrl-Alt-Del (actually, to change the boot keys to
  615.     leftShift-Alt-Del), use DEBOOT.COM.  Along with KEYKILL.COM, which
  616.     lets you disable up to three keys of your choice, it is at Simtel in
  617.     the file PD1:<MSDOS.KEYBOARD>KEYKILL.ARC.
  618.  
  619.     C programmers who simply want to make sure that the user can't
  620.     Ctrl-Break out of their program can use the ANSI-standard signal( )
  621.     function; the Borland compilers also offer ctrlbrk( ) for handling
  622.     Ctrl-Break.  However, if your program uses normal DOS input, the
  623.     characters ^C will appear on the screen when the user presses Ctrl-C
  624.     or Ctrl-Break.  There are many ways to work around that, including:
  625.     use INT 21 function 7, which allows redirection but doesn't display
  626.     the ^C (or echo any other character, for that matter); or use INT 16
  627.     function 0 or 10; or call _bios_keybrd( ) in MSC or bioskey( ) in
  628.     BC++; or hook INT 9 to discard Ctrl-C and Ctrl-Break before the
  629.     regular BIOS keyboard handler sees them; etc., etc.
  630.  
  631.     You should be aware that Ctrl-C and Ctrl-Break are processed quite
  632.     differently internally.  Ctrl-Break, like all keystrokes, is
  633.     processed by the BIOS code at INT 9 as soon as the user presses the
  634.     keys, even if earlier keys are still in the keyboard buffer:  by
  635.     default the handler at INT 1B is called.  Ctrl-C is not special to
  636.     the BIOS, nor is it special to DOS functions 6 and 7; it _is_
  637.     special to DOS functions 1 and 8 when at the head of the keyboard
  638.     buffer.  You will need to make sure BREAK is OFF to prevent DOS
  639.     polling the keyboard for Ctrl-C during non-keyboard operations.
  640.  
  641.     Some good general references are {Advanced MS-DOS} by Ray Duncan,
  642.     ISBN 1-55615-157-8; {8088 Assembler Language Programming:  The IBM
  643.     PC}, ISBN 0-672-22024-5, by Willen & Krantz; and {COMPUTE!'s Mapping
  644.     the IBM PC}, ISBN 0-942386-92-2.
  645.  
  646. Q304. How can I disable the print screen function?
  647.  
  648.     There are really two print screen functions:  1) print current
  649.     screen snapshot, triggered by PrintScreen or Shift-PrtSc or
  650.     Shift-grey*, and 2) turn on continuous screen echo, started and
  651.     stopped by Ctrl-P or Ctrl-PrtSc.
  652.  
  653.     1) Screen snapshot to printer
  654.        --------------------------
  655.  
  656.     The BIOS uses INT 5 for this.  Fortunately, you don't need to mess
  657.     with that interrupt handler.  The standard handler, in BIOSes dated
  658.     December 1982 or later, uses a byte at 0040:0100 (alias 0000:0500)
  659.     to determine whether a print screen is currently in progress.  If it
  660.     is, pressing PrintScreen again is ignored.  So to disable the screen
  661.     snapshot, all you have to do is write a 1 to that byte.  When the
  662.     user presses PrintScreen, the BIOS will think that a print screen is
  663.     already in progress and will ignore the user's keypress.  You can
  664.     re-enable PrintScreen by zeroing the same byte.
  665.  
  666.     Here's some simple code:
  667.  
  668.         void prtsc_allow(int allow) /* 0=disable, nonzero=enable */ {
  669.             unsigned char far* flag = (unsigned char far*)0x00400100UL;
  670.             *flag = (unsigned char)!allow;
  671.         }
  672.  
  673.     2) Continuous echo of screen to printer
  674.        ------------------------------------
  675.  
  676.     If ANSI.SYS is loaded, you can easily disable the continuous echo of
  677.     screen to printer (Ctrl-P or Ctrl-PrtSc).  Just redefine the keys by
  678.     "printing" strings like these to the screen (BASIC print, C printf,
  679.     Pascal Write statements, or ECHO command in batch files):
  680.  
  681.         <27>[0;114;"Ctrl-PrtSc disabled"p
  682.         <27>[16;"^P"p
  683.  
  684.     Change <27> in the above to an Escape character, ASCII 27.
  685.  
  686.     If you haven't installed ANSI.SYS, I can't offer an easy way to
  687.     disable the echo-screen-to-printer function.  Please send any tested
  688.     solutions to brown@ncoast.org and I'll add them to this list.
  689.  
  690.     Actually, you might not need to disable Ctrl-P and Ctrl-PrtSc.  If
  691.     your only concern is not locking up your machine, when you see the
  692.     "Abort, Retry, Ignore, Fail" prompt just press Ctrl-P again and then
  693.     I.  As an alternative, install one of the many print spoolers that
  694.     intercept printer-status queries and always return "Printer ready".
  695.  
  696. Q305. How can my program turn NumLock (CapsLock, ScrollLock) on or off?
  697.  
  698.     You need to twiddle bit 5, 6, or 4 of location 0040:0017.  Here's
  699.     some code:  lck( ) turns on a lock state, and unlck( ) turns it off.
  700.     (The status lights on some keyboards may not reflect the change.  If
  701.     yours is one, call INT 16 function 2, "get shift status", and that
  702.     may update them.  It will certainly do no harm.)
  703.  
  704.         #define NUM_LOCK  (1 << 5)
  705.         #define CAPS_LOCK (1 << 6)
  706.         #define SCRL_LOCK (1 << 4)
  707.         void lck(int shiftype) {
  708.             char far* kbdstatus = (char far*)0x00400017UL;
  709.             *kbdstatus |= (char)shiftype;
  710.         }
  711.         void unlck(int shiftype) {
  712.             char far* kbdstatus = (char far*)0x00400017UL;
  713.             *kbdstatus &= ~(char)shiftype;
  714.         }
  715.  
  716. Q306. How can I speed up the keyboard's auto-repeat?
  717.  
  718.     The keyboard speed has two components: delay (before a key that you
  719.     hold down starts repeating) and typematic rate (the speed once the
  720.     key starts repeating).  Most BIOSes since 1986 let software change
  721.     the delay and typematic rate by calling INT 16 function 3, "set
  722.     typematic rate and delay"; see Ralf Brown's interrupt list.  If you
  723.     have DOS 4.0 or later, you can use the MODE CON command that you'll
  724.     find in your DOS manual.
  725.  
  726.     On 83-key keyboards (mostly XTs), the delay and typematic rate can't
  727.     easily be changed.  According to the {PC Magazine} of 15 Jan 1991,
  728.     page 409, to adjust the typematic rate you need "a memory-resident
  729.     program which simply '[watches]' the keyboard to see if you're
  730.     holding down a key ... and after a certain time [starts] stuffing
  731.     extra copies of the held-down key into the buffer."  No source code
  732.     is given in that issue; but I'm told that the QUICKEYS utility that
  733.     {PC} published in 1986 does this sort of watching; you can download
  734.     source and object code in PD1:<MSDOS.PCMAG>VOL5N05.ARC from Simtel.
  735.  
  736. Q307. What is the SysRq key for?
  737.  
  738.     There is no standard use for the key.  The BIOS keyboard routines in
  739.     INT 16 simply ignore it; therefore so do the DOS input routines in
  740.     INT 21 as well as the keyboard routines in libraries supplied with
  741.     high-level languages.
  742.  
  743.     When you press or release a key, the keyboard triggers hardware line
  744.     IRQ1, and the CPU calls INT 9.  INT 9 reads the scan code from the
  745.     keyboard and the shift states from the BIOS data area.
  746.  
  747.     What happens next depends on whether your PC's BIOS supports an
  748.     enhanced keyboard (101 or 102 keys).  If so, INT 9 calls INT 15
  749.     function 4F to translate the scan code.  If the translated scan code
  750.     is 54 hex (for the SysRq key) then INT 9 calls INT 15 function 85
  751.     and doesn't put the keystroke into the keyboard buffer.  The default
  752.     handler of that function does nothing and simply returns.  (If your
  753.     PC has an older BIOS that doesn't support the extended keyboards,
  754.     INT 15 function 4F is not called.  Early ATs have 84-key keyboards,
  755.     so their BIOS calls INT 15 function 85 but nor 4F.)
  756.  
  757.     Thus your program is free to use SysRq for its own purposes, but at
  758.     the cost of some programming.  You could hook INT 9, but it's
  759.     probably easier to hook INT 15 function 85, which is called when
  760.     SysRq is pressed or released.
  761.  
  762. Q308. How can my program tell what kind of keyboard is on the system?
  763.  
  764.     Ralf Brown's Interrupt List includes MEMORY.LST, a detailed
  765.     breakdown by Robin Walker of the contents of the BIOS system block
  766.     that starts at 0040:0000.  Bit 4 of byte 0040:0096 is "1=enhanced
  767.     keyboard installed".  C code to test the keyboard type:
  768.         char far *kbd_stat_byte3 = (char far *)0x00400096UL;
  769.         if (0x10 & *kbd_stat_byte3)
  770.             /* 101- or 102-key keyboard is installed */
  771.  
  772.     {PC Magazine}'s 15 Jan 1991 issue suggests on page 412 that "for
  773.     some clones [the above test] is not foolproof".  If you use this
  774.     method in your program you should provide the user some way to
  775.     override this test, or at least some way to tell your program to
  776.     assume a non-enhanced keyboard.  The {PC Magazine} article suggests
  777.     a different approach to determining the type of keyboard.
  778.  
  779. Q309. How can I tell if input, output, or stderr has been redirected?
  780.  
  781.     Normally, input and output are associated with the console (i.e.,
  782.     with the keyboard and the screen, respectively).  If either is not,
  783.     you know that it has been redirected.  Some source code to check
  784.     this is available at the usual archive sites.
  785.  
  786.     If you program in Turbo Pascal, download the /pc/ts/tspa*.zip
  787.     collection of Turbo Pascal units from garbo; or from Simtel,
  788.     PD1:<MSDOS.TURBOPAS>TSPA*.ZIP.  (Choose TSPA3060.ZIP, TSPA3055.ZIP,
  789.     TSPA3050.ZIP, or TSPA3040.ZIP for Turbo Pascal 6.0, 5.5, 5.0, or 4.0
  790.     respectively.)  Source code is not included.  Also see the
  791.     information in garbo.uwasa.fi:/pc/ts/tsfaq*.zip Frequently Asked
  792.     Questions, the Turbo Pascal section.
  793.  
  794.     If you program in C, use isatty( ) if your implementation has it.
  795.     Otherwise, you can download PD1:<MSDOS.SYSUTL>IS_CON10.ZIP from
  796.     Simtel; it includes source code.
  797.  
  798.     Good references for the principles are {PC Magazine} 16 Apr 1991
  799.     (vol 10 nr 7) pg 374; Ray Duncan's {Advanced MS-DOS}, ISBN
  800.     1-55615-157-8, or Ralf Brown's interrupt list for INT 21 function
  801.     4400; and Terry Dettman and Jim Kyle's {DOS Programmer's Reference:
  802.     2d edition}, ISBN 0-88022-458-4, pp 602-603.
  803.  
  804. (continued in part 3)
  805. -- 
  806. Stan Brown, Oak Road Systems                      brown@Ncoast.ORG
  807. Cleveland, Ohio, USA
  808. Path: nlbbs!gator!news.dell.com!swrinde!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!ncoast!brown
  809. From: brown@NCoast.ORG (Stan Brown)
  810. Newsgroups: comp.os.msdos.programmer,news.answers
  811. Subject: comp.os.msdos.programmer FAQ part 3 of 4
  812. Message-ID: <msdos-faq.921220.3@NCoast.ORG>
  813. Date: Sun, 20 Dec 1992 20:14:13 GMT
  814. Expires: Wed, 3 Feb 1993 20:14:13 GMT
  815. References: <msdos-faq.921220.1@NCoast.ORG>
  816. Followup-To: comp.os.msdos.programmer
  817. Organization: Oak Road Systems, Cleveland Ohio USA
  818. Lines: 898
  819. Approved: news-answers-request@MIT.Edu
  820. Supersedes: <msdos-faq.921205.3@NCoast.ORG>
  821.  
  822. Archive-name: msdos-programmer-faq/part3
  823. Last-modified: 20 December 1922
  824.  
  825.  
  826. (continued from part 2)         (no warranty on the code or information)
  827.  
  828. If the posting date is more than six weeks in the past, see instructions
  829. in part 4 of this list for how to get an updated copy.
  830.  
  831.             Copyright (C) 1992  Stan Brown, Oak Road Systems
  832.  
  833.  
  834. section 4.  Disks and files
  835. ===========================
  836.  
  837. Q401. What drive was the PC booted from?
  838.  
  839.     Under DOS 4.0 or later, load 3305 hex into AX; do an INT 21.  DL is
  840.     returned with an integer indicating the boot drive (1=A:, etc.).
  841.  
  842. Q402. How can I boot from drive b:?
  843.  
  844.     Download PD1:<MSDOS.DSKUTL>BOOT_B.ZIP (shareware) from Simtel.  The
  845.     included documentation says it works by writing a new boot sector on
  846.     a disk in your a: drive that redirects the boot to your b: drive.
  847.  
  848. Q403. Which real and virtual disk drives are valid?
  849.  
  850.     Use INT 21 function 29 (parse filename).  Point DS:SI at a null-
  851.     terminated ASCII string that contains the drive letter and a colon,
  852.     point ES:DI at a 37-byte dummy FCB buffer, set AX to 2900h, and do
  853.     an INT 21.  On return, AL is FF if the drive is invalid, something
  854.     else if the drive is valid.  RAM disks and SUBSTed drives are
  855.     considered valid.
  856.  
  857.     Unfortunately, the b: drive is considered valid even on a single-
  858.     diskette system.  You can check that special case by interrogating
  859.     the BIOS equipment byte at 0040:0010.  Bits 7-6 contain the one less
  860.     than the number of diskette drives, so if those bits are zero you
  861.     know that b: is an invalid drive even though function 29 says it's
  862.     valid.
  863.  
  864.     Following is some code originally posted by Doug Dougherty, with my
  865.     fix for the b: special case, tested only in Borland C++ 2.0 (in
  866.     the small model):
  867.  
  868.         #include <dos.h>
  869.         void drvlist(void)  {
  870.             char *s = "A:", fcb_buff[37];
  871.             int valid;
  872.             for (   ;  *s<='Z';  (*s)++) {
  873.                 _SI = (unsigned) s;
  874.                 _DI = (unsigned) fcb_buff;
  875.                 _ES = _DS;
  876.                 _AX = 0x2900;
  877.                 geninterrupt(0x21);
  878.                 valid = _AL != 0xFF;
  879.                 if (*s == 'B'  &&  valid) {
  880.                     char far *equipbyte = (char far *)0x00400010UL;
  881.                     valid = (*equipbyte & (3 << 6)) != 0;
  882.                 }
  883.                 printf("Drive '%s' is %sa valid drive.\n",
  884.                         s, valid ? "" : "not ");
  885.             }
  886.         }
  887.  
  888. Q404. How can I make my single floppy drive both a: and b:?
  889.  
  890.     Under any DOS since DOS 2.0, you can put the command
  891.  
  892.         assign b=a
  893.  
  894.     into your AUTOEXEC.BAT file.  Then, when you type "DIR B:" you'll no
  895.     longer get the annoying prompt to insert diskette B (and the even
  896.     more annoying prompt to insert A the next time you type "DIR A:").
  897.  
  898.     You may be wondering why anybody would want to do this.  Suppose you
  899.     use two different machines, maybe one at home and one at work.  One
  900.     of them has only a 3.5" diskette drive; the other machine has two
  901.     drives, and b: is the 3.5" one.  You're bound to type "dir b:" on
  902.     the first one, and get the nuisance message
  903.  
  904.         Insert diskette for drive B: and press any key when ready.
  905.  
  906.     But if you assign drive b: to point to a:, you avoid this problem.
  907.  
  908.     Caution:  there are a few commands, such as DISKCOPY, that will not
  909.     work right on ASSIGNed or SUBSTed drives.  See the DOS manual for
  910.     the full list.  Before typing one of those commands, be sure to turn
  911.     off the mapping by typing "assign" without arguments.
  912.  
  913.     The DOS 5.0 manual says that ASSIGN is obsolete, and recommends the
  914.     equivalent form of SUBST: "subst b: a:\".  Unfortunately, if this
  915.     command is executed when a: doesn't hold a diskette, the command
  916.     fails.  ASSIGN doesn't have this problem, so I must advise you to
  917.     disregard that particular bit of advice in the DOS manual.
  918.  
  919. Q405. Why won't my C program open a file with a path?
  920.  
  921.     You've probably got something like the following code:
  922.  
  923.         char *filename = "c:\foo\bar\mumble.dat";
  924.         . . .  fopen(filename, "r");
  925.  
  926.     The problem is that \f is a form feed, \b is a backspace, and \m is
  927.     m.  Whenever you want a backslash in a string constant in C, you
  928.     must use two backslashes:
  929.  
  930.         char *filename = "c:\\foo\\bar\\mumble.dat";
  931.  
  932.     This is a feature of every C compiler, because Dennis Ritchie
  933.     designed C this way.  It's a problem only on MS-DOS systems, because
  934.     only DOS (and Atari ST/TT running TOS, I'm told) uses the backslash
  935.     in directory paths.  But even in DOS this backslash convention
  936.     applies _only_ to string constants in your source code.  For file
  937.     and keyboard input at run time, \ is just a normal character, so
  938.     users of your program would type in file specs at run time the same
  939.     way as in DOS commands, with single backslashes.
  940.  
  941.     Another possibility is to code all paths in source programs with /
  942.     rather than \ characters:
  943.  
  944.         char *filename = "c:/foo/bar/mumble.dat";
  945.  
  946.     Ralf Brown writes that "All versions of the DOS kernel accept either
  947.     forward or backslashes as directory separators.  I tend to use this
  948.     form more frequently than backslashes since it is easier to type and
  949.     read."  This applies to DOS function calls (and therefore to calls
  950.     to the file library of every programming language), but not to DOS
  951.     commands.
  952.  
  953. Q406. How can I redirect printer output to a file?
  954.  
  955.     My personal favorite utility for this purpose is PRN2FILE from {PC
  956.     Magazine}, available from Simtel as PD1:<MSDOS.PRINTER>PRN2FILE.ARC,
  957.     or from garbo as prn2file.zip in /pc/printer.  ({PC Magazine} has
  958.     given copies away as part of its utilities disks, so you may already
  959.     have a copy.)
  960.  
  961.     Check the PD1:<MSDOS.PRINTER> directory at Simtel, or /pc/printer
  962.     at garbo, for lots of other printer-redirection utilities.
  963.  
  964. Q407. How can my program open more files than DOS's limit of 20?
  965.  
  966.     (This is a summary of an article Ralf Brown posted on 8 August 1992.)
  967.  
  968.     There are separate limits on files and file handles.  For example,
  969.     DOS opens three files but five file handles:  CON (stdin, stdout,
  970.     and stderr), AUX (stdaux), and PRN (stdprn).
  971.  
  972.     The limit in FILES= in CONFIG.SYS is a system-wide limit on files
  973.     opened by all programs (including the three that DOS opens and any
  974.     opened by TSRs); each process has a limit of 20 handles (including
  975.     the five that DOS opens).  Example:  CONFIG.SYS has FILES=40.  Then
  976.     program #1 will be able to open 15 file handles.  Assuming that the
  977.     program actually does open 15 handles pointing to 15 different
  978.     files, other programs could still open a total of 22 files (40-3-15
  979.     = 22), though no one program could open more than 15 file handles.
  980.  
  981.     If you're running DOS 3.3 or later, you can increase the per-process
  982.     limit of 20 file handles by a call to INT 21 function 67, Set Handle
  983.     Count.  Your program is still limited by the system-wide limit on
  984.     open files, so you may also need to increase the FILES= value in
  985.     your CONFIG.SYS file (and reboot).  The run-time library that you're
  986.     using may have a fixed-size table of file handles, so you may also
  987.     need to get source code for the module that contains the table,
  988.     increase the table size, and recompile it.
  989.  
  990. Q408. How can I read, create, change, or delete the volume label?
  991.  
  992.     In DOS 5.0 (and, I believe, in 4.0 as well), there are actually two
  993.     volume labels: one, the traditional one, is an entry in the root
  994.     directory of the disk; and the other is in the boot record along
  995.     with the serial number (see next Q).  The DIR and VOL commands
  996.     report the traditional label; the LABEL command reports the
  997.     traditional one but changes both of them.
  998.  
  999.     In DOS 4.0 and later, use INT 21 function 69 to access the boot
  1000.     record's serial number and volume label together; see the next Q.
  1001.  
  1002.     Assume that by "volume label" you mean the traditional one, the one
  1003.     that DIR and VOL display.  Though it's a directory entry in the root
  1004.     directory, you can't change it using the newer DOS file-access
  1005.     functions (3C, 41, 43); instead, use the old FCB-oriented directory
  1006.     functions.  Specifically, you need to allocate a 64-byte buffer and
  1007.     a 41- byte extended FCB (file control block).  Call INT 21 AH=1A to
  1008.     find out whether there is a volume label.  If there is, AL returns 0
  1009.     and you can change the label using DOS function 17 or delete it
  1010.     using DOS function 13.  If there's no volume label, function 1A will
  1011.     return FF and you can create a label via function 16.  Important
  1012.     points to notice are that ? wildcards are allowed but * are not; the
  1013.     volume label must be space filled not null terminated.
  1014.  
  1015.     The following MSC 7.0 code worked for me in DOS 5.0; the functions
  1016.     it uses have been around since DOS 2.0.  The function parameter is 0
  1017.     for the current disk, 1 for a:, 2 for b:, etc.  It doesn't matter
  1018.     what your current directory is; these functions always search the
  1019.     root directory for volume labels.  (I didn't try to change the
  1020.     volume label of any networked drives.)
  1021.  
  1022.     // Requires DOS.H, STDIO.H, STRING.H
  1023.     void vollabel(unsigned char drivenum) {
  1024.         static unsigned char extfcb[41], dta[64], status, *newlabel;
  1025.         int chars_got = 0;
  1026.         #define DOS(buff,func) __asm { __asm mov dx,offset buff \
  1027.             __asm mov ax,seg buff  __asm push ds  __asm mov ds,ax \
  1028.             __asm mov ah,func  __asm int 21h  __asm pop ds \
  1029.             __asm mov status,al }
  1030.         #define getlabel(buff,prompt) newlabel = buff;  \
  1031.             memset(newlabel,' ',11);  printf(prompt);   \
  1032.             scanf("%11[^\n]%n", newlabel, &chars_got);  \
  1033.             if (chars_got < 11) newlabel[chars_got] = ' ';
  1034.  
  1035.         // Set up the 64-byte transfer area used by function 1A.
  1036.         DOS(dta, 1Ah)
  1037.         // Set up an extended FCB and search for the volume label.
  1038.         memset(extfcb, 0, sizeof extfcb);
  1039.         extfcb[0] = 0xFF;             // denotes extended FCB
  1040.         extfcb[6] = 8;                // volume-label attribute bit
  1041.         extfcb[7] = drivenum;         // 1=A, 2=B, etc.; 0=current drive
  1042.         memset(&extfcb[8], '?', 11);  // wildcard *.*
  1043.         DOS(extfcb,11h)
  1044.         if (status == 0) {            // DTA contains volume label's FCB
  1045.             printf("volume label is %11.11s\n", &dta[8]);
  1046.             getlabel(&dta[0x18], "new label (\"delete\" to delete): ");
  1047.             if (chars_got == 0)
  1048.                 printf("label not changed\n");
  1049.             else if (strncmp(newlabel,"delete     ",11) == 0) {
  1050.                 DOS(dta,13h)
  1051.                 printf(status ? "label failed\n" : "label deleted\n");
  1052.             }
  1053.             else {                    // user wants to change label
  1054.                 DOS(dta,17h)
  1055.                 printf(status ? "label failed\n" : "label changed\n");
  1056.             }
  1057.         }
  1058.         else {                        // no volume label was found
  1059.             printf("disk has no volume label.\n");
  1060.             getlabel(&extfcb[8], "new label (<Enter> for none): ");
  1061.             if (chars_got > 0) {
  1062.                 DOS(extfcb,16h)
  1063.                 printf(status ? "label failed\n" : "label created\n");
  1064.             }
  1065.         }
  1066.     }   // end function vollabel
  1067.  
  1068. Q409. How can I get the disk serial number?
  1069.  
  1070.     Use INT 21.  AX=6900 gets the serial number; AX=6901 sets it.  See
  1071.     Ralf Brown's interrupt list, or page 496 of the July 1992 {PC
  1072.     Magazine}, for details.
  1073.  
  1074.     This function also gets and sets the volume label, but it's the
  1075.     volume label in the boot record, not the volume label that a DIR
  1076.     command displays.  See the preceding Q.
  1077.  
  1078. Q410. What's the format of .OBJ, .EXE., .COM files?
  1079.  
  1080.     Please see section 2, "Compile and link".
  1081.  
  1082.  
  1083. section 5. Serial ports (COM ports)
  1084. ===================================
  1085.  
  1086. Q501. How do I set my machine up to use COM3 and COM4?
  1087.  
  1088.     Unless your machine is fairly old, it's probably already set up.
  1089.     After installing the board that contains the extra COM port(s),
  1090.     check the I/O addresses in word 0040:0004 or 0040:0006.  (In DEBUG,
  1091.     type "D 40:4 L4" and remember that every word is displayed low
  1092.     byte first, so if you see "03 56" the word is 5603.)  If those
  1093.     addresses are nonzero, your PC is ready to use the ports and you
  1094.     don't need the rest of this answer.
  1095.  
  1096.     If the I/O address words in the 0040 segment are zero after you've
  1097.     installed the I/O board, you need some code to store these values
  1098.     into the BIOS data segment:
  1099.  
  1100.         0040:0004  word  I/O address of COM3
  1101.         0040:0006  word  I/O address of COM4
  1102.         0040:0011  byte (bits 3-1): number of serial ports installed
  1103.  
  1104.     The documentation with your I/O board should tell you the port
  1105.     addresses.  When you know the proper port addresses, you can add
  1106.     code to your program to store them and the number of serial ports
  1107.     into the BIOS data area before you open communications.  Or you can
  1108.     use DEBUG to create a little program to include in your AUTOEXEC.BAT
  1109.     file, using this script:
  1110.  
  1111.             n SET_ADDR.COM      <--- or a different name ending in .COM
  1112.             a 100
  1113.             mov  AX,0040
  1114.             mov  DS,AX
  1115.             mov  wo [0004],aaaa <--- replace aaaa with COM3 address or 0
  1116.             mov  wo [0006],ffff <--- replace ffff with COM4 address or 0
  1117.             and  by [0011],f1
  1118.             or   by [0011],8    <--- use number of serial ports times 2
  1119.             mov  AH,0
  1120.             int  21
  1121.                                 <--- this line must be blank
  1122.             rCX
  1123.             1f
  1124.             rBX
  1125.             0
  1126.             w
  1127.             q
  1128.  
  1129. Q502. How do I find the I/O address of a COM port?
  1130.  
  1131.     Look in the four words beginning at 0040:0000 for COM1 through COM4.
  1132.     (The DEBUG command "D 40:0 L8" will do this.  Remember that words
  1133.     are stored and displayed low byte first, so a word value of 03F8
  1134.     will be displayed as F8 03.)  If the value is zero, that COM port is
  1135.     not installed (or you've got an old BIOS; see the preceding Q).  If
  1136.     the value is nonzero, it is the I/O address of the transmit/receive
  1137.     register for the COM port.  Each COM port occupies eight consecutive
  1138.     I/O addresses (though only seven are used by many chips).
  1139.  
  1140.     Here's some C code to find the I/O address:
  1141.  
  1142.         unsigned ptSel(unsigned comport) {
  1143.             unsigned io_addr;
  1144.             if (comport >= 1  &&  comport <= 4) {
  1145.                 unsigned far *com_addr = (unsigned far *)0x00400000UL;
  1146.                 io_addr = com_addr[comport-1];
  1147.             }
  1148.             else
  1149.                 io_addr = 0;
  1150.             return io_addr;
  1151.         }
  1152.  
  1153. Q503. But aren't the COM ports always at I/O addresses 3F8, 2F8, 3E8,
  1154.       and 2E8?
  1155.  
  1156.     The first two are usually right (though not always); the last two
  1157.     are different on many machines.
  1158.  
  1159. Q504. How do I configure a COM port and use it to transmit data?
  1160.  
  1161.     After hearing several recommendations, I looked at Joe Campbell's {C
  1162.     Programmer's Guide to Serial Communications}, ISBN 0-672-22584-0,
  1163.     and agree that it is excellent.  He gives complete details on how
  1164.     serial ports work, along with complete programs for doing polled or
  1165.     interrupt-driver I/O.  The book is quite thick, and none of it looks
  1166.     like filler.
  1167.  
  1168.     If Campbell's book is overkill for you, you'll find a good short
  1169.     description of serial I/O in {DOS 5: A Developer's Guide}, ISBN
  1170.     1-55851-177-6, by Al Williams.
  1171.  
  1172.     You may also want to look at an extended example in Borland's
  1173.     TechFax TI445, part of PD1:<MSDOS.TURBO-C> at Simtel.  Though
  1174.     written by Borland, much of it is applicable to other forms of C,
  1175.     and it should give you ideas for other programming languages.
  1176.  
  1177. section 6. Other hardware questions and problems
  1178. ================================================
  1179.  
  1180. Q601. Which 80x86 CPU is running my program?
  1181.  
  1182.     According to an article posted by Michael Davidson, Intel's approved
  1183.     code for distinguishing among 8086, 80286, 80386, and 80486 and for
  1184.     detecting the presence of an 80287 or 80387 is published in the
  1185.     Intel's 486SX processor manual (order number 240950-001).  You can
  1186.     download David Kirschbaum's improved version of this from Simtel as
  1187.     PD1:<MSDOS.SYSUTL>CPUID593.ZIP.
  1188.  
  1189.     According to an article posted by its author, WCPU041.ZIP knows the
  1190.     differences between DX and SX varieties of 386 and 486 chips, and
  1191.     can also detect a math coprocessor.  It's in PD1:<MSDOS.SYSUTL> at
  1192.     Simtel.
  1193.  
  1194. Q602. How can a C program send control codes to my printer?
  1195.  
  1196.     If you just fprintf(stdprn, ...), C will translate some of your
  1197.     control codes.  The way around this is to reopen the printer in
  1198.     binary mode:
  1199.  
  1200.         prn = fopen("PRN", "wb");
  1201.  
  1202.     You must use a different file handle because stdprn isn't an lvalue.
  1203.     By the way, PRN or LPT1 must not be followed by a colon in DOS 5.0.
  1204.  
  1205.     There's one special case, Ctrl-Z (ASCII 26), the DOS end-of-file
  1206.     character.  If you try to send an ASCII 26 to your printer, DOS
  1207.     simply ignores it.  To get around this, you need to reset the
  1208.     printer from "cooked" to "raw" mode.  Microsoft C users must use int
  1209.     21 function 44, "get/set device information".  Turbo C and Borland
  1210.     C++ users can use ioctl to accomplish the same thing:
  1211.  
  1212.         ioctl(fileno(prn), 1, ioctl(fileno(prn),0) & 0xFF | 0x20, 0);
  1213.  
  1214.     An alternative approach is simply to write the printer output into a
  1215.     disk file, then copy the file to the printer with the /B switch.
  1216.  
  1217.     A third approach is to bypass DOS functions entirely and use the
  1218.     BIOS printer functions at INT 17.  If you also fprintf(stdprn,...)
  1219.     in the same program, you'll need to use fflush( ) to synchronize
  1220.     fprintf( )'s buffered output with the BIOS's unbuffered.
  1221.  
  1222.     By the way, if you've opened the printer in binary mode from a C
  1223.     program, remember that outgoing \n won't be translated to carriage
  1224.     return/line feed.  Depending on your printer, you may need to send
  1225.     explicit \n\r sequences.
  1226.  
  1227. Q603. How can I redirect printer output to a file?
  1228.  
  1229.     Please see section 4, "Disks and files", for the answer.
  1230.  
  1231. Q604. Which video adapter is installed?
  1232.  
  1233.     The technique below should work if your BIOS is not too old.  It
  1234.     uses three functions from INT 10, the BIOS video interrupt.  (If
  1235.     you're using a Borland language, you may not have to do this the
  1236.     hard way.  Look for a function called DetectGraph or something
  1237.     similar.)
  1238.  
  1239.     Set AH=12h, AL=0, BL=32h; INT 10h.  If AL is 12h, you have a VGA.
  1240.     If not, set AH=12h, BL=10h; INT 10h.  If BL is 0,1,2,3, you have an
  1241.     EGA with 64,128,192,256K memory.  If not, set AH=0Fh; INT 10h.  If
  1242.     AL is 7, you have an MDA (original monochrome adapter) or Hercules;
  1243.     if not, you have a CGA.
  1244.  
  1245.     I've tested this for my VGA and got the right answer; but I can't
  1246.     test it for the other equipment types.  Please let me know by email
  1247.     at brown@ncoast.org if your results vary.
  1248.  
  1249. Q605. How do I switch to 43- or 50-line mode?
  1250.  
  1251.     Download PD1:<MSDOS.SCREEN>VIDMODE.ZIP from Simtel or one of the
  1252.     mirror sites.  It contains .COM utilities and .ASM source code.
  1253.  
  1254. Q606. How can I find the Microsoft mouse position and button status?
  1255.  
  1256.     Use INT 33 function 3, described in Ralf Brown's interrupt list.
  1257.  
  1258.     The Windows manual says that the Logitech mouse is compatible with
  1259.     the Microsoft one, so I assume the interrupt will work the same.
  1260.  
  1261.     Also, see the directory PD1:<MSDOS.MOUSE> at Simtel.
  1262.  
  1263. Q607. How can I access a specific address in the PC's memory?
  1264.  
  1265.     First check the library that came with your compiler.  Many vendors
  1266.     have some variant of peek and poke functions; in Turbo Pascal use
  1267.     the pseudo-arrays Mem, MemW, and MemL.  As an alternative, you can
  1268.     construct a far pointer:  use Ptr in Turbo Pascal, MK_FP in the
  1269.     Turbo C family, and FP_OFF and FP_SEG in Microsoft C.
  1270.  
  1271.     Caution:  Turbo C and Turbo C++ also have FP_OFF and FP_SEG macros,
  1272.     but they can't be used to construct a pointer.  In Borland C++ those
  1273.     macros work the same as in Microsoft C, but MK_FP is easier to use.
  1274.  
  1275.     By the way, it's not useful to talk about "portable" ways to do
  1276.     this.  Any operation that is tied to a specific memory address is
  1277.     not likely to work on another kind of machine.
  1278.  
  1279. Q608. How can I read or write my PC's CMOS memory?
  1280.  
  1281.     There are a great many public-domain utilities that do this.  These
  1282.     were available for download from Simtel as of 31 March 1992:
  1283.  
  1284.     PD1:<MSDOS.AT>
  1285.     CMOS14.ZIP     5965  920817  Saves/restores CMOS to/from file
  1286.     CMOSER11.ZIP  28323  910721  386/286 enhanced CMOS setup program
  1287.     CMOSRAM.ZIP   76096  920214  Save AT/386/486 CMOS data to file and restore
  1288.     ROM2.ARC      20497  900131  Save AT and 386 CMOS data to file and restore
  1289.     SETUP21.ARC   24888  880613  Setup program which modifies CMOS RAM
  1290.     VIEWCMOS.ARC  15374  900225  Display contents of AT CMOS RAM, w/C source
  1291.  
  1292.     At garbo, /pc/ts/tsutle17.zip contains a CMOS program to check and
  1293.     display CMOS memory, but not to write to it.
  1294.  
  1295.     I have heard good reports of CMOS299.ZIP, available in the pc.dir
  1296.     directory of cantva.canterbury.ac.nz [132.181.30.3].
  1297.  
  1298.     Of the above, my only experience is with CMOSRAM, which seems to
  1299.     work fine.  It contains an excellent (and witty) .DOC file that
  1300.     explains the hardware involved and gives specific recommendations
  1301.     for preventing disaster or recovering from it.  It's $5 shareware.
  1302.  
  1303.     Robert Jourdain's {Programmer's Problem Solver for the IBM PC, XT,
  1304.     and AT} has code for accessing the CMOS RAM, according to an article
  1305.     posted in this newsgroup.
  1306.  
  1307. Q609. How can I access memory beyond 640K?
  1308.  
  1309.     I'm outside my expertise on this one, but in late 1992 Jamshid
  1310.     Afshar (jamshid@emx.utexas.edu) kindly supplied the following, which
  1311.     incorporates some corrections agreed with Duncan Murdoch (dmurdoch@
  1312.     mast.queensu.ca).  If you have any corrections or comments, please
  1313.     send them to both the above addresses.
  1314.  
  1315.     ...........................(begin quote)............................
  1316.     1. Use XMS or EMS memory.  XMS is preferable in most cases, but
  1317.     some machines won't provide it.  There are some libraries available
  1318.     at Simtel to access XMS or EMS.  The disadvantage is that you
  1319.     don't allocate the memory as you would with malloc() (or `new' in
  1320.     C++).  I believe it also requires that you lock this memory when in
  1321.     use.  This means your code is not easily ported to other (and
  1322.     future) operating systems and that your code is more convoluted than
  1323.     it would be under a "real" os.  The advantage is that the library
  1324.     works with compilers since Turbo C 2.0 (I think) and that your
  1325.     program will easily run on even 286s.
  1326.  
  1327.     2.  Program under MS Windows.  MS Windows functions as a 16-bit DOS
  1328.     Extender (see #3).  Borland/Turbo C++ 3.x includes EasyWin [and
  1329.     Microsoft C/C++ 7.0 has QuickWin --ed.] which is a library that
  1330.     automatically lets you compile your current code using C/C++
  1331.     standard input or <conio.h> into a MS Windows program so your code
  1332.     can immediately allocate many MBs of memory (Windows enhanced mode
  1333.     even does virtual memory).  The disadvantage is that like any 16-bit
  1334.     Extender a single malloc() is restricted to 64K (unless you want to
  1335.     mess with huge pointers in Windows).  Also, EasyWin's screen output
  1336.     is significantly slower than a DOS character-mode program's and you
  1337.     must of course run the program from Windows.
  1338.  
  1339.     3.  Use a 16-bit or 32-bit DOS Extender.  This is definitely the
  1340.     best solution from the programmer's standpoint.  You just allocate
  1341.     as much memory as you need using malloc() or 'new'.  A 16-bit
  1342.     Extender still has 16-bit ints and restricts arrays to 64K, but a
  1343.     32-bit Extender has 32-bits ints (which makes porting a lot of UNIX
  1344.     code easier) so there are no 64K limits.  A 32-bit Extender requires
  1345.     a 32-bit compiler and the program will not run on 286s.  Some
  1346.     Extenders also do virtual memory.  Using an Extender doesn't require
  1347.     source code changes and unlike option #1 your code is portable and
  1348.     not obsolete in a few months.  Your options for this solution are:
  1349.  
  1350.     - Buy PharLap's 16-bit Extender that works with BC++ 3.0+ and MSC
  1351.       (just requires a relink).  Note, the BC++ 3.1 upgrade came with
  1352.       PharLap "lite".  Pharlap's 32-bit Extender works with 32-bit
  1353.       compilers like [?]
  1354.  
  1355.     - Get the GNU (free,copylefted) gcc 2.x compiler which DJ Delorie
  1356.       ported from UNIX and which uses his 32-bit Extender.  It supports
  1357.       C and C++, but the Extender is VCPI which means neither the
  1358.       compiler nor programs it produces will run in a DOS session under
  1359.       Windows.  FTP to barnacle.erc.clarkson.edu and get
  1360.       pub/msdos/djgpp/readme.
  1361.  
  1362.     - Get a 32-bit compiler or one that comes with a DOS Extender.
  1363.       Zortech comes with 16-bit and a 32-bit Extenders (no debugger for
  1364.       32-bit programs, but Flashtek sells one).  Watcom also makes a C
  1365.       [and C++?] 32-bit compiler.  [If anyone else has products or plans
  1366.       to announce, please let me know.]
  1367.  
  1368.     - Buy Borland Pascal 7.0.  It includes a 16 bit royalty-free DOS
  1369.       extender using the same interface as MS Windows.  It functions
  1370.       under a DPMI server like Windows or QDPMI from Quarterdeck, and
  1371.       also provides its own server which you can distribute with your
  1372.       programs.
  1373.  
  1374.     4.  This option doesn't really count since it's not a solution in
  1375.     DOS, but you could switch to a full 32-bit operating system like
  1376.     OS/2 2.0 or UNIX (or NT when it comes out).  I believe Win32 will
  1377.     allow you to write 32-bit Windows programs.  [can someone fill me in
  1378.     on what exactly Win32 is?]
  1379.     ............................(end quote).............................
  1380.  
  1381.  
  1382. section 7. Other software questions and problems
  1383. ================================================
  1384.  
  1385. Q701. How can a program reboot my PC?
  1386.  
  1387.     You can generate a "cold" boot or a "warm" boot.  A cold boot is
  1388.     the same as turning the power off and on; a warm boot is the same as
  1389.     Ctrl-Alt-Del and skips the power-on self test.
  1390.  
  1391.     For a warm boot, store the hex value 1234 in the word at 0040:0072.
  1392.     For a cold boot, store 0 in that word.  Then, if you want to live
  1393.     dangerously, jump to address FFFF:0000.  Here's C code to do it:
  1394.  
  1395.         /* WARNING:  data loss possible */
  1396.         void bootme(int want_warm)  /* arg 0 = cold boot, 1 = warm */ {
  1397.             void (far* boot)(void) = (void (far*)(void))0xFFFF0000UL;
  1398.             unsigned far* type = (unsigned far*)0x00400072UL;
  1399.             *type = (want_warm ? 0x1234 : 0);
  1400.             (*boot)( );
  1401.         }
  1402.  
  1403.     What's wrong with that method?  It will boot right away, without
  1404.     closing files, flushing disk caches, etc.  If you boot without
  1405.     flushing a write-behind disk cache (if one is running), you could
  1406.     lose data or even trash your hard drive.
  1407.  
  1408.     There are two methods of signaling the cache to flush its buffers:
  1409.     (1) simulate a keyboard Ctrl-Alt-Del in the keystroke translation
  1410.     function of the BIOS (INT 15 function 4F), and (2) issue a disk
  1411.     reset (DOS function 0D).  Most disk-cache programs hook one or both
  1412.     of those interrupts, so if you use both methods you'll probably be
  1413.     safe.
  1414.  
  1415.     When user code simulates a Ctrl-Alt-Del, one or more of the programs
  1416.     that have hooked INT 15 function 4F can ask that the key be ignored by
  1417.     clearing the carry flag.  For example, HyperDisk does this when it
  1418.     has started but not finished a cache flush.  So if the carry flag
  1419.     comes back cleared, the boot code has to wait a couple of cluck
  1420.     ticks and then try again.  (None of this matters on older machines
  1421.     whose BIOS can't support 101- or 102-key keyboards; see "What is the
  1422.     SysRq key for?" in section 3, "Keyboard".)
  1423.  
  1424.     Here's C code that tries to signal the disk cache (if any) to flush:
  1425.  
  1426.         #include <dos.h>
  1427.         void bootme(int want_warm)  /* arg 0 = cold boot, 1 = warm */ {
  1428.             union REGS reg;
  1429.             void    (far* boot)(void) = (void (far*)(void))0xFFFF0000UL;
  1430.             unsigned far* boottype    =     (unsigned far*)0x00400072UL;
  1431.             char     far* shiftstate  =         (char far*)0x00400017UL;
  1432.             unsigned      ticks;
  1433.             int           time_to_waste;
  1434.             /* Simulate reception of Ctrl-Alt-Del: */
  1435.             for (;;) {
  1436.                 *shiftstate |= 0x0C;    /* turn on Ctrl & Alt */
  1437.                 reg.x.ax = 0x4F53;      /* 0x53 = Del's scan code */
  1438.                 reg.x.cflag = 1;        /* sentinel for ignoring key */
  1439.                 int86(0x15, ®, ®);
  1440.                 /* If carry flag is still set, we've finished. */
  1441.                 if (reg.x.cflag)
  1442.                     break;
  1443.                 /* Else waste some time before trying again: */
  1444.                 reg.h.ah = 0;
  1445.                 int86(0x1A, ®, ®);/* system time into CX:DX */
  1446.                 ticks = reg.x.dx;
  1447.                 for (time_to_waste = 3;  time_to_waste > 0;  ) {
  1448.                     reg.h.ah = 0;
  1449.                     int86(0x1A, ®, ®);
  1450.                     if (ticks != reg.x.dx)
  1451.                         ticks = reg.x.dx , --time_to_waste;
  1452.                 }
  1453.             }
  1454.             /* Issue a DOS disk reset request: */
  1455.             reg.h.ah = 0x0D;
  1456.             int86(0x21, ®, ®);
  1457.             /* Set boot type and boot: */
  1458.             *boottype = (want_warm ? 0x1234 : 0);
  1459.             (*boot)( );
  1460.         }
  1461.  
  1462. Q702. How can I time events with finer resolution than the system
  1463.       clock's 55 ms (about 18 ticks a second)?
  1464.  
  1465.     The following files, among others, can be downloaded from Simtel:
  1466.  
  1467.     PD1:<MSDOS.AT>
  1468.     ATIM.ARC       5946  881126  Precision program timing for AT
  1469.  
  1470.     PD1:<MSDOS.C>
  1471.     MILLISEC.ZIP  37734  911205  MSC/asm src for millisecond res timing
  1472.     MSCHRT3.ZIP   53708  910605  High-res timer toolbox for MSC 5.1
  1473.     MSEC_12.ZIP    8484  920320  High-def millisec timer v1.2 (C,ASM)
  1474.     ZTIMER11.ZIP  77625  920428  Microsecond timer for C, C++, ASM
  1475.  
  1476.     PD1:<MSDOS.TURBO-C>
  1477.     TCHRT3.ZIP    53436  910606  High-res timer toolbox for Turbo C 2.0
  1478.     TCTIMER.ARC   20087  891030  High-res timing of events for Turbo C
  1479.  
  1480.     PD1:<MSDOS.TURBOPAS>
  1481.     BONUS507.ARC 150435  900205  [Turbo Pascal source: high-res timing]
  1482.  
  1483.     Pascal users can download source code in /pc/turbopas/bonus507.zip
  1484.     at garbo.
  1485.  
  1486. Q703. How can I find the error level of the previous program?
  1487.  
  1488.     First, which previous program are you talking about?  If your
  1489.     current program ran another one, when the child program ends its
  1490.     error level is available to the program that spawned it.  Most
  1491.     high-level languages provide a way to do this; for instance, in
  1492.     Turbo Pascal it's Lo(DosExitCode) and the high byte gives the way in
  1493.     which the child terminated.  In Microsoft C, the exit code of a
  1494.     synchronous child process is the return value of the spawn-type
  1495.     function that creates the process.
  1496.  
  1497.     If your language doesn't have a function to return the error code
  1498.     of a child process, you can use INT 21 function 4D (get return
  1499.     code).  By the way, this will tell you the child's exit code and the
  1500.     manner of its ending (normal, Ctrl-C, critical error, or TSR).
  1501.  
  1502.     It's much trickier if the current program wants to get the error
  1503.     level of the program that ran and finished before this one started.
  1504.     G.A.Theall has published source and compiled code to do this; you
  1505.     can download it from Simtel as PD1:<MSDOS.BATUTL>ERRLVL12.ZIP.  (The
  1506.     code uses undocumented features in DOS 3.3 through 5.0.  Theall says
  1507.     in the .DOC file that the values returned under 4DOS or other
  1508.     replacements won't be right.)
  1509.  
  1510. Q704. How can a program set DOS environment variables?
  1511.  
  1512.     Program functions that read or write "the environment" typically
  1513.     access only the program's copy of the environment.  What this Q
  1514.     really wants to do is to modify the active environment, the one that
  1515.     is affected by SET commands in batch files or at the DOS prompt.
  1516.     You need to do some programming to find the active environment, and
  1517.     that programming varies for different versions of DOS.
  1518.  
  1519.     A fairly well-written article in {PC Magazine} volume 8 number 20
  1520.     (1989 Nov 28), pages 309-314, explains how to find the active
  1521.     environment, and includes Pascal source code.  The article hints at
  1522.     how to change the environment, and suggests creating paths longer
  1523.     than 128 characters as one application.
  1524.  
  1525.     In searching Simtel for source code, I found many possibilities.  I
  1526.     liked PD1:<MSDOS.SYSUTL>RBSETNV1.ZIP of the ones I looked at (not
  1527.     all of them).  It includes some utilities to manipulate the environ-
  1528.     ment, with source code in C.
  1529.  
  1530.     You can also use a call to INT 2E, Pass Command to Interpreter for
  1531.     Execution; see Ralf Brown's interrupt list for details and cautions.
  1532.  
  1533. Q705. How can I change the switch character to - from /?
  1534.  
  1535.     Under DOS 5.0, you can't -- not completely, anyway.  INT 21 function
  1536.     3700, get switch character, always returns a '/' (hex 2F) -- and the
  1537.     DOS commands don't even call that function, but hard code '/' as the
  1538.     switch character.
  1539.  
  1540.     Some history:  DOS used to let you change the switch character by
  1541.     using SWITCHAR= in CONFIG.SYS or by calling DOS function 3701.  DOS
  1542.     commands and other programs called DOS function 3700 to find out the
  1543.     switch character.  If you changed the switch character to '-' (the
  1544.     usual choice), you could then type "dir c:/c700 -p" rather than "dir
  1545.     c:\c700 /p".  Under DOS 4.0, the DOS commands ignored the switch
  1546.     character but functions 3700 and 3701 still worked and could be used
  1547.     by other programs.  Under DOS 5.0, even those functions no longer
  1548.     work, though all DOS functions still accept '/' or '\' in file
  1549.     specs.
  1550.  
  1551.     You can reactivate the functions to get and set switchar by using
  1552.     programs like SLASH.ZIP or the sample TSR called SWITCHAR in
  1553.     AMISL091.ZIP (see "How can I write a TSR?", below.)  DOS commands
  1554.     will still use the slash, but non-DOS programs that call DOS func-
  1555.     tion 3700 will use your desired switch character.  (DOS replacements
  1556.     like 4DOS may honor the switch character for internal commands.)
  1557.  
  1558.     Some readers may wonder why this is even an issue.  Making '-' the
  1559.     switch character frees up the front slash to separate names in the
  1560.     path part of a file spec.  This is easier for the ten-fingered to
  1561.     type, and it's one less difference to remember for commuters between
  1562.     DOS and Unix.  The switch character is the only issue, since all the
  1563.     INT 21 functions accept '/' or '\' to separate directory names.
  1564.  
  1565. Q706. Why does my interrupt function behave strangely?
  1566.  
  1567.     Interrupt service routines can be tricky, because you have to do
  1568.     some things differently from "normal" programs.  If you make a
  1569.     mistake, debugging is a pain because the symptoms may not point at
  1570.     what's wrong.  Your machine may lock up or behave erratically, or
  1571.     just about anything else can happen.  Here are some things to look
  1572.     for.  (See the next Q for general help before you have a problem.)
  1573.  
  1574.     First, did you fail to set up the registers at the start of your
  1575.     routine?  When your routine begins executing, you can count on
  1576.     having CS point to your code segment and SS:SP point to some valid
  1577.     stack (of unknown length), and that's it.  In particular, an
  1578.     interrupt service routine must set DS to DGROUP before accessing any
  1579.     data in its data segments.  (If you're writing in a high-level
  1580.     language, the compiler may generate this code for you automatically;
  1581.     check your compiler manual.  For instance, in Borland and Microsoft
  1582.     C, give your function the "interrupt" attribute.)
  1583.  
  1584.     Did you remember to turn off stack checking when compiling your
  1585.     interrupt server and any functions it calls?  The stack during the
  1586.     interrupt is not where the stack-checking code expects it to be.
  1587.     (Caution:  Some third-party libraries have stack checking compiled
  1588.     in, so you can't call them from your interrupt service routine.)
  1589.  
  1590.     Next, are you calling any DOS functions (INT 21, 25, or 26) in your
  1591.     routine?  DOS is not re-entrant.  This means that if your interrupt
  1592.     happens to be triggered while the CPU is executing a DOS function,
  1593.     calling another DOS function will wreak havoc.  (Some DOS functions
  1594.     are fully re-entrant, as noted in Ralf Brown's interrupt list.
  1595.     Also, your program can test, in a way too complicated to present
  1596.     here, when it's safe to call non-re-entrant DOS functions.  See INT
  1597.     28 and functions 34, 5D06, 5D0B of INT 21; and consult {Undocumented
  1598.     DOS} by Andrew Schulman.  Your program must read both the "InDOS
  1599.     flag" and the "critical error flag".)
  1600.  
  1601.     Is a function in your language library causing trouble?  Does it
  1602.     depend on some initializations done at program startup that is no
  1603.     longer available when the interrupt executes?  Does it call DOS (see
  1604.     preceding paragraph)?  For example, in both Borland and Microsoft C
  1605.     the memory-allocation functions (malloc, etc..) and standard I/O
  1606.     functions (scanf, printf) call DOS functions and also depend on
  1607.     setups that they can't get at from inside an interrupt.  Many other
  1608.     library functions have the same problem, so you can't use them
  1609.     inside an interrupt function without special precautions.
  1610.  
  1611.     Is your routine simply taking too long?  This can be a problem if
  1612.     you're hooking on to the timer interrupt, INT 1C or INT 8.  Since
  1613.     that interrupt expects to be called 18.2 times a second, your
  1614.     routine -- plus any others hooked to the same interrupts -- must
  1615.     execute in less than 55 ms.  If they use even a substantial fraction
  1616.     of that time, you'll see significant slowdowns of your foreground
  1617.     program.  For a good writeup, download INTSHARE (from ni.funet.fi
  1618.     in pub/msdos/simtel20/info or from Simtel in PD1:<MSDOS.INFO>).
  1619.  
  1620.     Did you forget to restore all registers at the end of your routine?
  1621.  
  1622.     Did you chain improperly to the original interrupt?  You need to
  1623.     restore the stack to the way it was upon entry to your routine, then
  1624.     do a far jump (not call) to the original interrupt service routine.
  1625.     (The process is a little different in high-level languages.)
  1626.  
  1627. Q707. How can I write a TSR (terminate-stay-resident) utility?
  1628.  
  1629.     Several books can help you with this.
  1630.  
  1631.     - Ray Duncan's {Advanced MS-DOS}, ISBN 1-55615-157-8, gives a brief
  1632.       checklist intended for experienced programmers.  The ISBN is for
  1633.       the second edition, through DOS 4; but check to see whether the
  1634.       DOS 5 version is available yet.
  1635.  
  1636.     - {DOS 5:  A Developer's Guide} by Al Williams, ISBN 1-55851-177-6,
  1637.       goes into a little more detail, 90 pages worth!
  1638.  
  1639.     - Pascal programmers might look at {The Ultimate DOS Programmer's
  1640.       Manual} by John Mueller and Wallace Wang, ISBN 0-8306-3534-3, for
  1641.       an extended example in mixed Pascal and assembler.
  1642.  
  1643.     - For a pure assembler treatment, check Steven Holzner's {Advanced
  1644.       Assembly Language}, ISBN 0-13-663014-6.  He has a book with the
  1645.       same title out from Brady Press, but it's about half as long as
  1646.       this one.
  1647.  
  1648.     - For C programmers, there's a chapter in Herbert Schildt's {The Art
  1649.       of C:  Elegant Programming Solutions}.  I haven't seen the book,
  1650.       but a posted article recommended it.
  1651.  
  1652.     At Simtel, check PD1:<MSDOS.ASMUTL>AMISL091.ZIP, which contains Ralf
  1653.     Brown's assembly-language implementation of the Alternate Multiplex
  1654.     Interrupt Specification, with utilities in C.  The spec itself is
  1655.     PD1:<MSDOS.INFO>ALTMPX35.ZIP.  Both are also available at CS.CMU.EDU
  1656.     [128.2.222.173] in /afs/cs/user/ralf/pub (change directory with a
  1657.     single command and use lower-case filenames).
  1658.  
  1659.     You might want to download PD1:<MSDOS.ASMUTL>TEMPLATE.ZIP from
  1660.     Simtel.  It's Douglas Boling's MASM template for a TSR.
  1661.  
  1662.     Finally, there are commercial products, of which TesSeRact (for
  1663.     C-language TSRs) is one of the best known.
  1664.  
  1665. Q708. How can I write a device driver?
  1666.  
  1667.     Many books answer this in detail.  Among them are {Advanced MS-DOS}
  1668.     and {DOS 5: A Developer's Guide}, cited in the preceding Q.
  1669.     Michael Tischer's {PC System Programming}, ISBN 1-55755-036-0, has
  1670.     an extensive treatment, as does Dettman and Kyle's {DOS Programmer's
  1671.     Reference: 2d Edition}, ISBN 0-88022-458-4.  For a really in-depth
  1672.     treatment, look for a specialized book like Robert Lai's {Writing
  1673.     MS-DOS Device Drivers}, ISBN 0-201-13185-4.
  1674.  
  1675. Q709. What can I use to manage versions of software?
  1676.  
  1677.     In PD1:<MSDOS.PGMUTL> at Simtel you'll find RCS56DOS.ZIP.  I haven't
  1678.     used it myself, but I understand this is a port of the Unix RCS
  1679.     utility, and is no longer limited to one-character extensions on
  1680.     filenames (so .CPP and .BAS are fine).
  1681.  
  1682. Q710. What's this "null pointer assignment" after my C program executes?
  1683.  
  1684.     Somewhere in your program, you assigned a value _through_ a pointer
  1685.     without first assigning a value _to_ the pointer.  (This might have
  1686.     been something like a strcpy or memcpy with a pointer as its first
  1687.     argument, not necessarily an actual assignment statement.)  Your
  1688.     program may look like it ran correctly, but if you get this message
  1689.     you can be certain that there's a bug somewhere.
  1690.  
  1691.     Microsoft and Borland C, as part of their exit code (after a return
  1692.     from your main function), check whether the location 0000 in your
  1693.     data segment contains a different value from what you started with;
  1694.     if so, they infer that you must have used an uninitialized pointer.
  1695.  
  1696.     To track down the problem, you can put exit( ) statements at various
  1697.     spots in the program and narrow down where the uninitialized pointer
  1698.     is being used by seeing which added exit( ) makes the null-pointer
  1699.     message disappear.  Or, in the debugger, set a watch at location
  1700.     0000 in your data segment, assuming you're in small or medium model.
  1701.     (If data pointers are 32 bits, as in the compact and large models, a
  1702.     null pointer will overwrite the interrupt vectors at 0000:0000 and
  1703.     probably lock up your machine.)
  1704.  
  1705.     Under MSC/C++ 7.0, you can declare the undocumented library function
  1706.  
  1707.         extern _cdecl _nullcheck(void);
  1708.  
  1709.     and then sprinkle calls to _nullcheck( ) through your program at
  1710.     regular intervals.
  1711.  
  1712.     Borland's TechFax document #TI726 discusses the null pointer
  1713.     assignment from a Borland point of view.  Download file BCHELP10.ZIP
  1714.     from PD1:<MSDOS.TURBO-C> at Simtel.
  1715.  
  1716. (continued in part 4)
  1717. -- 
  1718. Stan Brown, Oak Road Systems                      brown@Ncoast.ORG
  1719. Cleveland, Ohio, USA
  1720. Path: nlbbs!gator!news.dell.com!swrinde!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!ncoast!brown
  1721. From: brown@NCoast.ORG (Stan Brown)
  1722. Newsgroups: comp.os.msdos.programmer,news.answers
  1723. Subject: comp.os.msdos.programmer FAQ part 4 of 4
  1724. Message-ID: <msdos-faq.921220.4@NCoast.ORG>
  1725. Date: Sun, 20 Dec 1992 20:15:05 GMT
  1726. Expires: Wed, 3 Feb 1993 20:15:05 GMT
  1727. References: <msdos-faq.921220.1@NCoast.ORG>
  1728. Followup-To: comp.os.msdos.programmer
  1729. Organization: Oak Road Systems, Cleveland Ohio USA
  1730. Lines: 446
  1731. Approved: news-answers-request@MIT.Edu
  1732. Supersedes: <msdos-faq.921205.4@NCoast.ORG>
  1733.  
  1734. Archive-name: msdos-programmer-faq/part4
  1735. Last-modified: 20 December 1922
  1736.  
  1737.  
  1738. (continued from part 3)         (no warranty on the code or information)
  1739.  
  1740. If the posting date is more than six weeks in the past, see instructions
  1741. in part 4 of this list for how to get an updated copy.
  1742.  
  1743.             Copyright (C) 1992  Stan Brown, Oak Road Systems
  1744.  
  1745.  
  1746. section A. Downloads
  1747. ====================
  1748.  
  1749. QA01. What is garbo?  What is wustl?
  1750.  
  1751.     These are alternative archive sites.  Please try to use the site for
  1752.     your continent; see next Q.
  1753.  
  1754. QA02. What are Simtel and "mirror sites"?  What good are they?
  1755.  
  1756.     The U.S. Government maintains a massive archive of useful software
  1757.     and info files at the SIMTEL20 site.  This includes scads of
  1758.     utilities, plus source code from {PC Magazine}, {Dr Dobbs Journal},
  1759.     and others.  You can use Simtel by ftp (wsmr-simtel20.army.mil =
  1760.     192.88.110.20) or (if necessary) email.  To find out how, look for
  1761.     these monthly articles in comp.binaries.ibm.pc.archives :
  1762.  
  1763.         How to find files in the SIMTEL20 msdos collection
  1764.         SIMTEL20 archive info for Internet FTP users
  1765.         How to order SIMTEL20 files via e-mail
  1766.  
  1767.     Another important archive site is garbo (at the University of Vaasa,
  1768.     Finland).  garbo is set up differently from Simtel but contains many
  1769.     of the same useful files.
  1770.  
  1771.     Please try first at the site nearest you:
  1772.  
  1773.     - Europe and Asia: look first at garbo; for prerecorded instructions
  1774.       (about 29K), email Timo Salmi (ts@uwasa.fi).
  1775.  
  1776.     - Oceania:  try archie.au first.  (This is different from the Archie
  1777.       mail server, archie-l@cs.mcgill.ca.)  Paul Brooks has written to
  1778.       say that it "mirrors garbo and simtel-20 (in /micros/pc/simtel-20,
  1779.       /micros/pc/garbo) as well as many other archives.  Telnetting to
  1780.       'archie.au' and logging on as 'archie' (no password) will access
  1781.       the Oceanic ARCHIE server."  Email Craig Warren (ccw@archie.au)
  1782.       for instructions if needed.
  1783.  
  1784.     - North America: try SIMTEL20 (a/k/a Simtel) first; see above for
  1785.       instructions or email Keith Petersen (w8sdz@vela.acs.oakland.edu).
  1786.       Also see the Simtel mirrors OAK.Oakland.Edu and ftp.uu.net, or the
  1787.       SIMTEL20 & garbo mirror wuarchive.wustl.edu [128.252.135.4].
  1788.  
  1789.     General cautions and guidelines:
  1790.  
  1791.     - Some of the mirrors may lag occasionally, or might not have all
  1792.       the files.
  1793.  
  1794.     - If you send an email message and don't get a reply within a few
  1795.       days, there are two likely causes.  Most likely the Reply-to path
  1796.       in your message is not valid; your sysadmin can check this and
  1797.       correct it if necessary and then you can send your message again.
  1798.       Occasionally a machine goes down for an extended period, which may
  1799.       prevent a timely reply to your message.  If you're sure your
  1800.       message bears a good reply path and you haven't got a reply in a
  1801.       week or so, you might send your message again, once.  Don't post
  1802.       it as an article in a newsgroup.
  1803.  
  1804. QA03. Where do I find program <mumble>?
  1805.  
  1806.     There are several newsgroups to help; comp.binaries.ibm.pc.wanted is
  1807.     generally the best place to ask your question.  Please review the
  1808.     guidelines in "What other newsgroups should I know about?" in
  1809.     section 1, "General questions".  See also the next Q.
  1810.  
  1811. QA04. How can I check Simtel or garbo before I post a request for a
  1812.       program?
  1813.  
  1814.     What a good idea!  It will save your time and save net resources
  1815.     too.  Simtel and garbo have indexes of their contents, which you can
  1816.     download and use in searching off line.
  1817.  
  1818.     garbo has an index file, /pc/INDEX, an annotated list, frequently
  1819.     updated, of the MS-DOS files there; to save download time, get the
  1820.     packed form /pc/INDEX.ZIP.  The news file, /pc/pd2/news-pd2 contains
  1821.     selected news on all MS-DOS directories at garbo.
  1822.  
  1823.     Simtel's index files are all in PD1:<MSDOS.FILEDOCS>, and are
  1824.     updated several times a month.  SIMLIST.ZIP is in text format.  But
  1825.     you may prefer the file SIMIBM.ZIP, which is comma-delimited for
  1826.     easy use with any of these search facilities:
  1827.  
  1828.     - Two search programs are SIMTEL35.ARC and SIMDIR22.ZIP.  Of the
  1829.       two, I find I use SIMDIR much more often.
  1830.  
  1831.     - dBASE III or IV users can load the index from SIMLIST.ZIP using
  1832.       instructions in SIMIBM.INF and SIMIBM.DB3.
  1833.  
  1834.     - PC-FILE users should get SIMIBM.HDR, which tells how to use
  1835.       SIMIBM.IBM.
  1836.  
  1837. QA05. How do I download and decode a program I found?
  1838.  
  1839.     See the "starter kit" in comp.binaries.ibm.pc, usually posted on the
  1840.     first and 15th of every month.  Most binaries are posted and sent
  1841.     through email in 'uuencode' format.  The starter kit contains a
  1842.     uudecode program to turn this file back into a binary.
  1843.  
  1844.     If you can't wait (if?, bwaa-haa-haa), you can get the starter kit
  1845.     via ftp or email.  By ftp, access pit-manager.mit.edu (18.172.1.27)
  1846.     and look for the following file or one with a similar name:
  1847.  
  1848.         /pub/usenet/comp.binaries.ibm.pc/v17i7:_s.k,_C_S_s_K_(p_01_01)
  1849.  
  1850.     By email, send mail-server@pit-manager.mit.edu a message with blank
  1851.     subject and the following lines of text in the body:
  1852.  
  1853.         send usenet/comp.binaries.ibm.pc/v17i7:_s.k,_C_S_s_K_(p_01_01)
  1854.         send usenet/comp.binaries.ibm.pc/index
  1855.  
  1856.     The first command sends the starter kit, unless the version number
  1857.     has changed.  If it has, the first command will fail, so look at
  1858.     the index that you get in response to the second command and re-send
  1859.     the first command with the correct version number.
  1860.  
  1861.     If you're using Kermit, remember to set file type binary before
  1862.     issuing the send command.  By the way, the uuencoded file is bigger
  1863.     than the binary, so you'll save connect time if you can uudecode it
  1864.     and then download the binary file.
  1865.  
  1866. QA06. Where is UUDECODE?
  1867.  
  1868.     You can find it in Simtel, but it's easier to take it from the
  1869.     "starter kit" mentioned in the preceding Q.
  1870.  
  1871.     If you're logged in at a Unix site, there's almost certainly a
  1872.     uudecode there:  just type "uudecode" followed by a space and the
  1873.     file name.  The binary file is 25% smaller than the uuencoded file,
  1874.     so you'll save connect time if you can uudecode it on the Unix host
  1875.     and then download the binary file.  Remember: set file type binary.
  1876.  
  1877. QA07. Why do I get errors when extracting from a ZIP file I downloaded?
  1878.  
  1879.     There are many possible causes, but two of them probably account for
  1880.     95% of all problems.  (1) Did you remember to set your file-transfer
  1881.     protocol to binary mode, at both ends if necessary?  (2) Are you
  1882.     using the current version of PKUNZIP?  (See section B, "Vendors and
  1883.     products".)  The vast majority of stuff in archive sites requires
  1884.     PKZIP version 1.10 to extract correctly.  It causes confusion that
  1885.     older versions of PKZIP aren't smart enough to tell you that the
  1886.     problem is with the extraction program and not with the file you're
  1887.     trying to extract from.
  1888.  
  1889.  
  1890. section B. Vendors and products
  1891. ===============================
  1892.  
  1893. QB01. How can I contact Borland?
  1894.  
  1895.     Borland has set up these email addresses.  However, none of them is
  1896.     for technical support such as help with finding your own programming
  1897.     errors and explaining compiler messages.
  1898.  
  1899.     - bp7-info@borland.com will reply to any message with 17K of info on
  1900.       Borland Pascal with Objects 7.0 and Turbo Pascal 7.0.
  1901.  
  1902.     - customer-support@borland.com is for questions about prices and
  1903.       features of products, replacing bad or missing disks, info on
  1904.       upgrades, etc.  They do not accept emailed credit-card numbers.
  1905.  
  1906.     - bugs@borland.com will take "a well-documented bug report" and send
  1907.       an automated response, but will not give you a workaround or a
  1908.       scheduled fix date or even confirm that it is or is not considered
  1909.       a bug.  "The purpose of bugs@borland.com is to improve future
  1910.       products sooner, not as a substitute for tech support channels."
  1911.  
  1912.     Tech support is provided through Compuserve (GO BOR), by voice phone
  1913.     at +1 408 438 5300, by FAX at (800) 822-4269 in U.S. (use Touch-Tone
  1914.     voice phone), on a BBS at +1 408 439 9096, and by mail at
  1915.  
  1916.         Technical Support Department
  1917.         Borland International
  1918.         P.O. Box 660001
  1919.         Scotts Valley CA 95067-0001, USA.
  1920.  
  1921.     You'll need to give your product's name, version, and serial number.
  1922.  
  1923.     Borland's TechFax documents are also available at Simtel.  Download
  1924.     PD1:<MSDOS.TURBO-C>BCHELP10.ZIP.  These documents are detailed
  1925.     answers to common questions about Turbo C and Borland C products,
  1926.     and aggregate about four times the size of this file.
  1927.  
  1928.     Finally, in the 31 Mar 1992 issue of {PC Magazine}, an ad over the
  1929.     signature of Philippe Kahn, Borland's chairman, says "I want to make
  1930.     sure that I get your feedback about our dBASE products.  Call my
  1931.     voice mail directly at (800) 851-2122 with your critiques and
  1932.     suggestions."
  1933.  
  1934. QB02. How can I contact Microsoft?
  1935.  
  1936.     Individual employees of Microsoft (not MicroSoft, please!) post here
  1937.     sometimes.  Their addresses all take the form person@microsoft.com.
  1938.     However, Microsoft as a company does not provide product support
  1939.     through the Internet, as far as I'm aware.  Technical support
  1940.     through your modem is available on Compuserve (GO MICROSOFT).
  1941.  
  1942.     If you want to place an order or get general pre-sales information,
  1943.     call the appropriate sales and service number:
  1944.  
  1945.         U.S. end-user sales                   (800) 426-9400
  1946.         U.S. corporate/gov't/reseller/
  1947.                  educational sales            (800) 227-4679
  1948.         Canadian sales                        (800) 568-3503
  1949.         International sales                  +1 206 936-8661
  1950.  
  1951.     For tech support you must make an ordinary long-distance phone call.
  1952.     Microsoft has separate incoming phone numbers for many products.
  1953.     Since it's your nickel, first check your documentation to see if a
  1954.     phone number is listed.  Here are phone numbers (as of 1 June 1992)
  1955.     for a few products of most interest to the readers of this group:
  1956.  
  1957.         C/C++               (206) 635-7007
  1958.         MASM                (206) 646-5109
  1959.         DOS Upgrade Users   (206) 646-5104 (for 90 days after first call)
  1960.         Windows Users       (206) 637-6098
  1961.  
  1962.     If you can't find the direct number any other way, call the "master"
  1963.     numbers below or the sales numbers a few paragraphs above.  You'll
  1964.     get the "voice mail phone tree from h-ll" but you'll eventually get
  1965.     to the right department.  They don't provide technical assistance,
  1966.     but a voice menu will help you find the current phone number for the
  1967.     department you need.
  1968.  
  1969.         U.S. end-user product support         (206) 454-2030
  1970.         U.S. languages support                (206) 637-7096
  1971.  
  1972.     You can also write to Microsoft Product Support, 16011 NE 36th Way,
  1973.     Box 97017, Redmond WA 98073-9717, USA.
  1974.  
  1975. QB03. What's the current version of PKZIP?
  1976.  
  1977.     The current version is 1.10 (PKZIP110.EXE).  It is available from
  1978.     Simtel as PD1:<MSDOS.ZIP>PKZ110EU.EXE, which is the same as the
  1979.     standard version except it doesn't offer authenticity verification
  1980.     (the -AV indicators) because of U.S. law.  Remember that PKZIP is
  1981.     shareware and you're expected to pay for it if you use it.  Current
  1982.     price is $25, or $47 for a free upgrade when the next version is
  1983.     released.
  1984.  
  1985.     Since early 1992, PKWARE has been running ads in computer magazines
  1986.     announcing 2.0; but it seems to be vaporware.  The latest actual
  1987.     version, 1.93, is a test version not in general release, and not
  1988.     guaranteed compatible with the eventual official release.  Several
  1989.     versions that have been called 2.0, 2.01, or 2.2 are at best hacked
  1990.     versions of that beta-test version and at worst trojans that trash
  1991.     your hard disk.  A version 3.05 on wuarchive (and possibly
  1992.     elsewhere) is definitely not authorized and may bear a virus.
  1993.  
  1994.     By the way, if you're attempting to register a shareware copy of
  1995.     PKZIP 1.1, be aware that PKWARE's address has changed.  The current
  1996.     address, according to a CIAC (ciac@llnl.gov) bulletin, is
  1997.  
  1998.         PKWARE Inc.
  1999.         9025 N. Deerwood Drive
  2000.         Brown Deer, WI 53223 USA
  2001.         Voice: +1 414 354-8699    BBS: +1 414 354-8670
  2002.  
  2003. QB04. What's in Borland Pascal/Turbo Pascal 7.0?
  2004.  
  2005.     You can send email to bp7-info@borland.com and get an automatic
  2006.     reply of the 17K information file from Borland, or you can FTP
  2007.     the same think (6k, ZIPped) as /pc/turbopas/bp7-info.zip from
  2008.     garbo.uwasa.fi.
  2009.  
  2010. QB05. What's in Microsoft C/C++ 7.0?
  2011.  
  2012.     spoiler:  Yes, it includes the Windows 3.1 SDK, with an option to
  2013.     build applications that run on 3.0 and 3.1.
  2014.  
  2015.     According to the {Getting Started} booklet, the compiler needs 4 MB
  2016.     of RAM, an 80386 or better, and 8-27 MB on your hard disk.  (An
  2017.     email correspondent said Microsoft said it will run on an 80286, but
  2018.     very slowly).  C/C++ comes on nine 3.5" 1.44 MB diskettes, plus one
  2019.     for the source profiler and 11 more for the Windows System Develop-
  2020.     ment Kit (SDK); it's also available on 5.25 diskettes.
  2021.  
  2022.     The Programmer's WorkBench (PWB) and CodeView (CV) run in Windows or
  2023.     DOS.  According to the README.TXT file, "Microsoft C/C++ version 7.0
  2024.     requires DPMI services.  If you wish to use Windows as your develop-
  2025.     ment environment, Windows provides DPMI services for you.  To use
  2026.     MS-DOS as your development environment you must install 386-Max to
  2027.     provide these services."   A copy of Qualitas 386-Max is included.
  2028.  
  2029.     The upgrade includes everything in the compiler except printed ref-
  2030.     erence manuals for the Windows SDK (which is documented on disk).
  2031.     The manuals in my copy of upgrade are:
  2032.  
  2033.         Getting Started
  2034.         Environment and Tools
  2035.         Programming Techniques
  2036.         Run-Time Library Reference
  2037.         C Language Reference
  2038.         C++ Tutorial
  2039.         C++ Language Reference
  2040.         Class Libraries User's Guide
  2041.         Class Libraries Reference
  2042.         Comprehensive Index and Errors Reference (indexes all the above)
  2043.         Quick Reference Guide (card shows options for tools)
  2044.         Source Profiler User's Guide
  2045.         Class Libraries reference card
  2046.         Windows SDK: Getting Started
  2047.         Windows SDK: Programming Tools
  2048.         Windows SDK: Setup Toolkit for Windows
  2049.  
  2050.     The remaining printed manuals for the SDK for Windows 3.1 come with
  2051.     the compiler but not with the upgrade.  They are:
  2052.  
  2053.         Guide to Programming
  2054.         Programmers' Reference Volume 1: Overview
  2055.         "       "       "       "     2: Functions
  2056.         "       "       "       "     3: Messages, Structures and Macros
  2057.         "       "       "       "     4: Resources
  2058.         Multimedia Programmer's Guide
  2059.         Multimedia Programmer's Reference
  2060.         MS Windows for Pen Computing: Programmer's Reference
  2061.         The Windows Interface: An Application Design Guide
  2062.         The Win32 Application Programming Interface: An Overview
  2063.  
  2064.     Pricing:
  2065.  
  2066.     - compiler: $499 list, about $300 from mail-order companies
  2067.  
  2068.     - upgrade from any version of a C or C++ compiler from Microsoft,
  2069.       Borland, Watcom, or Zortech/Symantec: $139 list -- to order, call
  2070.       Microsoft sales and service listed earlier in this section
  2071.  
  2072.     - printed docs for Windows 3.1 SDK: $150 list (order form included
  2073.       with the upgrade)
  2074.  
  2075.  
  2076. section C. More information
  2077. ===========================
  2078.  
  2079. QC01. Are there any good on-line references for PC hardware components?
  2080.  
  2081.     I have heard good reports of HELPPC21.ZIP, downloadable from Simtel
  2082.     in PD1:<MSDOS.INFO>.  There's an info file in the same directory,
  2083.     HELPPC21.INF.  At garbo, it's /pc/programming/helppc21.zip.
  2084.  
  2085.     This hypertext system contains much information on ports and other
  2086.     hardware, as well as some overlap with Ralf Brown's interrupt list
  2087.     (see next Q).  It is shareware ($25).
  2088.  
  2089. QC02. Are there any good on-line references for PC interrupts?
  2090.  
  2091.     The definitive work is Ralf Brown's interrupt list, which is packed
  2092.     with information on documented and (officially) undocumented BIOS
  2093.     and DOS interrupts, DOS tables, and interrupts hooked by many
  2094.     software packages.
  2095.  
  2096.     The interrupt list comes from CS.CMU.EDU [128.2.222.173] in
  2097.     /afs/cs/user/ralf/pub (switch there with a *single* command) as
  2098.     inter32a.zip, inter32b.zip, and inter32c.zip.  At Simtel it's in
  2099.     PD1:<MSDOS.INFO>INTER32A.ZIP, INTER32B.ZIP and INTER32C.ZIP (about
  2100.     805K before un-ZIPping).  At garbo it's in /pc/programming as
  2101.     inter32a.zip, inter32b.zip, and inter32c.zip.  These versions were
  2102.     uploaded in mid-September 1992; updates are announced in
  2103.     comp.binaries.ibm.pc.archives every few months.
  2104.  
  2105.     If you'd rather not download the list, you can get it in book form,
  2106.     split up by subject, as {PC Interrupts:  A Programmer's Reference to
  2107.     BIOS, DOS, and Third-Party Calls} by Ralf Brown and Jim Kyle
  2108.     (Addison-Wesley; ISBN 0-201-57797-6).  This corresponds to INTER26
  2109.     with the most important new material from INTER27, so the on-line
  2110.     list contains more current information than the book.  (The on-line
  2111.     list has also grown quite a lot since the book was published.)
  2112.  
  2113. QC03. What and where is "Ralf Brown's interrupt list"?
  2114.  
  2115.     See the preceding Q.
  2116.  
  2117. QC04. Where can I find lex, yacc, and language grammars?
  2118.  
  2119.     The FAQ list of the comp.compilers newsgroup answers this for Basic,
  2120.     C, Pascal, and other languages.  See later in this section.
  2121.  
  2122. QC05. What's the best book to learn programming?
  2123.  
  2124.     Sorry, this FAQ list cannot settle religious arguments.
  2125.  
  2126.     Much of the heat over this topic arises because each person believes
  2127.     that the book that he or she learned from is the best book.  But my
  2128.     observation is that different people have very different experiences
  2129.     of the same book.  The only person who can tell you which is the
  2130.     best book for learning a given topic is you.
  2131.  
  2132.     Your best bet is to go to a fairly well-stocked bookstore when you
  2133.     have a couple of hours to spare.  Start at one end of the shelf and
  2134.     work your way methodically through every book that looks like it
  2135.     might cover what you want to learn.  Look at the tables of contents;
  2136.     read a page or two from each book.  Then make your decision.  If
  2137.     money is a problem, or if you're not sure of your choice, check out
  2138.     your top two or three from your library.
  2139.  
  2140. QC06. Where are FAQ lists archived?
  2141.  
  2142.     Many are crossposted to news.answers.  That newsgroup should have a
  2143.     long expiry time at your site; if not, talk to your sysadmin.
  2144.  
  2145.     FAQ lists are available by anonymous FTP from pit-manager.mit.edu
  2146.     [18.172.1.27] in files with names like
  2147.  
  2148.         /pub/usenet/news.answers/C-faq/faq
  2149.  
  2150.     and by email from mail-server@pit-manager.mit.edu.  For instructions
  2151.     about the mail server, send a message with "help" and "index" on
  2152.     different lines.
  2153.  
  2154. QC07. Where can I get the latest copy of this FAQ list?
  2155.  
  2156.     It is posted every month to news.answers in such a way that it
  2157.     should stick around until the following month's version has been
  2158.     posted.  Please check news.answers first, looking for the Subject
  2159.     line "comp.os.msdos.programmer FAQ".
  2160.  
  2161.     If the article has expired from your site's news.answers, or your
  2162.     site doesn't get news.answers, you can retrieve the latest version
  2163.     of this list as /pub/usenet/news.answers/msdos-programmer-faq/part1
  2164.     through part4 via FTP at pit-manager.mit.edu [18.172.1.27].  This
  2165.     list is also stored as garbo.uwasa.fi:/pc/doc-net/faqpYYMM.zip,
  2166.     replacing YYMM by the year and month of the latest list, e.g. 9210.
  2167.  
  2168.     If the article is unavailable from news.answers and you don't have
  2169.     ftp, send a message with blank subject and contents
  2170.         send usenet/news.answers/msdos-programmer-faq/part1
  2171.         send usenet/news.answers/msdos-programmer-faq/part2
  2172.         send usenet/news.answers/msdos-programmer-faq/part3
  2173.         send usenet/news.answers/msdos-programmer-faq/part4
  2174.     to mail-server@pit-manager.mit.edu.
  2175.  
  2176. (end of comp.os.msdos.programmer FAQ)
  2177. -- 
  2178. Stan Brown, Oak Road Systems                      brown@Ncoast.ORG
  2179. Cleveland, Ohio, USA
  2180.